private KerberosAuthorizationDataPACSignature(KerberosAuthorizationDataPACEntryType type, byte[] data, KerberosChecksumType sig_type,
                                               byte[] signature, int?rodc_id)
     : base(type, data)
 {
     SignatureType  = sig_type;
     Signature      = signature;
     RODCIdentifier = rodc_id;
 }
        internal static bool Parse(KerberosAuthorizationDataPACEntryType type, byte[] data, out KerberosAuthorizationDataPACEntry entry)
        {
            entry = null;

            if (data.Length < 4)
            {
                return(false);
            }

            int signature_length = 0;
            KerberosChecksumType signature_type = (KerberosChecksumType)BitConverter.ToInt32(data, 0);

            switch (signature_type)
            {
            case KerberosChecksumType.HMAC_MD5:
                signature_length = 16;
                break;

            case KerberosChecksumType.HMAC_SHA1_96_AES_128:
            case KerberosChecksumType.HMAC_SHA1_96_AES_256:
                signature_length = 12;
                break;

            default:
                signature_length = data.Length - 4;
                break;
            }

            byte[] signature = new byte[signature_length];
            Buffer.BlockCopy(data, 4, signature, 0, signature_length);
            int?rodc_id    = null;
            int total_size = 4 + signature_length;

            if (data.Length - total_size >= 2)
            {
                rodc_id = BitConverter.ToUInt16(data, total_size);
            }

            entry = new KerberosAuthorizationDataPACSignature(type, data, signature_type, signature, rodc_id);
            return(true);
        }
Exemplo n.º 3
0
        internal static KerberosChecksum Parse(DERValue value)
        {
            if (!value.CheckSequence())
            {
                throw new InvalidDataException();
            }
            KerberosChecksumType type = 0;

            byte[] data = null;
            foreach (var next in value.Children)
            {
                if (next.Type != DERTagType.ContextSpecific)
                {
                    throw new InvalidDataException();
                }
                switch (next.Tag)
                {
                case 0:
                    type = (KerberosChecksumType)next.ReadChildInteger();
                    break;

                case 1:
                    data = next.ReadChildOctetString();
                    break;

                default:
                    throw new InvalidDataException();
                }
            }

            if (type == 0 || data == null)
            {
                throw new InvalidDataException();
            }
            if (type == KerberosChecksumType.GSSAPI && KerberosChecksumGSSApi.Parse(data, out KerberosChecksum chksum))
            {
                return(chksum);
            }
            return(new KerberosChecksum(type, data));
        }
Exemplo n.º 4
0
 private protected KerberosChecksum(KerberosChecksumType type, byte[] data)
 {
     ChecksumType = type;
     Checksum     = data;
 }
Exemplo n.º 5
0
 private KerberosChecksumGSSApi(KerberosChecksumType type, byte[] data)
     : base(type, data)
 {
 }