Exemplo n.º 1
0
 public SignedUrl(CryptoKeyPayloadType payloadType, string plaintextPayload)
 {
     this.PayloadType  = payloadType;
     this.UtcTimestamp = DateTime.UtcNow;
     this.Payload      = CryptoUtils.Encrypt(Encoding.UTF8.GetBytes(plaintextPayload), payloadType, out this.keyVersion, out this.InitializationVector);
     string[] hashComponents = new string[]
     {
         this.ToQueryStringFragment(null, false)
     };
     this.MessageAuthenticationCode = HashUtility.ComputeHash(hashComponents, this.HashTypeForPayload);
 }
Exemplo n.º 2
0
 public string ValidateHashAndDecryptPayload()
 {
     string[] hashComponents = new string[]
     {
         this.ToQueryStringFragment(null, false)
     };
     byte[] array = HashUtility.ComputeHash(hashComponents, this.HashTypeForPayload);
     if (array.Length == this.MessageAuthenticationCode.Length)
     {
         if (!array.Where((byte t, int i) => t != this.MessageAuthenticationCode[i]).Any <byte>())
         {
             return(Encoding.UTF8.GetString(CryptoUtils.Decrypt(this.Payload, this.PayloadType, this.KeyVersion, this.InitializationVector)));
         }
     }
     throw new SecurityException("failed to validate hash and decrypt payload");
 }
Exemplo n.º 3
0
 // Token: 0x0600019C RID: 412 RVA: 0x0000B4CE File Offset: 0x000096CE
 public static byte[] ComputeHash(string[] hashComponents, CryptoKeyPayloadType payloadKey)
 {
     return(HashUtility.ComputeHash(hashComponents, payloadKey, 1));
 }