static void DoAsserts(HashAlgorithm algorithm, byte[] data, TagHash tag)
 {
     Assert.AreEqual(ILTagId.Hash, tag.TagId);
     Assert.AreEqual(algorithm, tag.Algorithm);
     Assert.AreEqual(data.Length, tag.Data?.Length ?? 0);
     Assert.AreEqual(data, tag.Data);
 }
 public Parts(string id, TagHash publicKeyHash, byte[] encryptedKey, byte[] encryptedIV)
 {
     if (string.IsNullOrWhiteSpace(id))
     {
         throw new ArgumentException("Must provide a non-empty id for this reading key", nameof(id));
     }
     ReaderId      = id;
     PublicKeyHash = publicKeyHash;
     EncryptedKey  = encryptedKey ?? throw new System.ArgumentNullException(nameof(encryptedKey));
     EncryptedIV   = encryptedIV.Required();
 }
 public Parts(KeyPurpose[] purposes, string name, string description, TagPubKey pubKey, KeyStrength strength, BaseKeyId keyId, IEnumerable <AppPermissions> permissions)
 {
     if (string.IsNullOrWhiteSpace(name))
     {
         throw new ArgumentNullException(nameof(name));
     }
     Version     = InterlockKeyVersion;
     Name        = name;
     Purposes    = purposes.Required();
     PublicKey   = pubKey.Required();
     Description = description;
     Strength    = strength;
     if (Actionable && permissions.None())
     {
         Purposes = Purposes.Where(pu => pu != KeyPurpose.Action).ToArray(); // Remove Action Purpose
     }
     Permissions = permissions;
     Identity    = new KeyId(TagHash.HashSha256Of(_hashable));
     Id          = keyId ?? Identity;
 }
 public static TagHash HashOf(this string s) => TagHash.HashSha256Of(s.UTF8Bytes());
 protected BaseKeyId(byte type, TagHash hash) : base(type, hash.Required().Algorithm, hash.Data)
 {
 }
Exemplo n.º 6
0
 public KeyId(TagHash hash) : base(_keyId, hash)
 {
 }
 public OwnerId(TagHash hash) : base(TypeId, hash)
 {
 }
 public TagReadingKey(string id, TagHash publicKeyHash, byte[] encryptedKey, byte[] encryptedIV)
     : base(ILTagId.ReadingKey, new Parts(id, publicKeyHash, encryptedKey, encryptedIV))
 {
 }