Exemplo n.º 1
0
 private static byte[] BinaryFromTicksKindScope(long ticks, Canary15.CanaryKind kind)
 {
     ticks &= 1152921504606846960L;
     if (kind == Canary15.CanaryKind.CertConstKeyHmac)
     {
         ticks |= 1152921504606846976L;
     }
     return(BitConverter.GetBytes(ticks));
 }
Exemplo n.º 2
0
 private byte[] ComputeHash(byte[] userContextIdBinary, byte[] timeStampBinary, string logonUniqueKey, out string logData)
 {
     Canary15.CanaryKind canaryKind = Canary15.GetCanaryKind(timeStampBinary);
     byte[] result;
     byte[] bytes = new UnicodeEncoding().GetBytes(logonUniqueKey);
     result = this.ComputeHmac(new byte[][] {
         userContextIdBinary,
         timeStampBinary,
         bytes
     });
     logData = Canary15.FormatLogData(canaryKind);
     return(result);
 }
Exemplo n.º 3
0
        public Canary15(string logonUniqueKey, string certpath, string certpass, Canary15.CanaryKind canaryKind)
        {
            this.certpath = certpath;
            this.certpass = certpass;
            byte[] userContextIdBinary = Guid.NewGuid().ToByteArray();
            byte[] timeStampBinary     = Canary15.BinaryFromTicksKindScope(DateTime.UtcNow.Ticks, canaryKind);
            string logData;

            byte[] hashBinary = this.ComputeHash(userContextIdBinary, timeStampBinary, logonUniqueKey, out logData);
            this.Init(userContextIdBinary, timeStampBinary, logonUniqueKey, hashBinary, logData);
            this.IsRenewed       = true;
            this.IsAboutToExpire = false;
        }
Exemplo n.º 4
0
        private void Init(byte[] userContextIdBinary, byte[] timeStampBinary, string logonUniqueKey, byte[] hashBinary, string logData)
        {
            long canaryTicks = Canary15.GetCanaryTicks(timeStampBinary);

            this.kind            = Canary15.GetCanaryKind(timeStampBinary);
            this.CreationTime    = new DateTime(canaryTicks, DateTimeKind.Utc);
            this.IsRenewed       = false;
            this.IsAboutToExpire = Canary15.IsNearExpiration(canaryTicks);
            byte[] array = new byte[userContextIdBinary.Length + timeStampBinary.Length + hashBinary.Length];
            userContextIdBinary.CopyTo(array, 0);
            timeStampBinary.CopyTo(array, userContextIdBinary.Length);
            hashBinary.CopyTo(array, userContextIdBinary.Length + timeStampBinary.Length);
            this.UserContextId  = new Guid(userContextIdBinary).ToString("N");
            this.LogonUniqueKey = logonUniqueKey;
            this.canaryString   = Canary15.Encode(array);
            this.LogData        = logData;
        }
Exemplo n.º 5
0
 private static string FormatLogData(Canary15.CanaryKind kind)
 {
     return(string.Format(CultureInfo.InvariantCulture, "{0}", kind.ToString()));
 }