Esempio n. 1
0
        public void DecodeX509BasicConstraintsExtension(byte[] encoded, out bool certificateAuthority, out bool hasPathLengthConstraint, out int pathLengthConstraint)
        {
            unsafe
            {
                bool localCertificateAuthority    = false;
                bool localHasPathLengthConstraint = false;
                int  localPathLengthConstraint    = 0;

                encoded.DecodeObject(
                    CryptDecodeObjectStructType.X509_BASIC_CONSTRAINTS,
                    delegate(void *pvDecoded, int cbDecoded)
                {
                    Debug.Assert(cbDecoded >= sizeof(CERT_BASIC_CONSTRAINTS_INFO));
                    CERT_BASIC_CONSTRAINTS_INFO *pBasicConstraints = (CERT_BASIC_CONSTRAINTS_INFO *)pvDecoded;
                    localCertificateAuthority    = (pBasicConstraints->SubjectType.pbData[0] & CERT_BASIC_CONSTRAINTS_INFO.CERT_CA_SUBJECT_FLAG) != 0;
                    localHasPathLengthConstraint = pBasicConstraints->fPathLenConstraint != 0;
                    localPathLengthConstraint    = pBasicConstraints->dwPathLenConstraint;
                }
                    );

                certificateAuthority    = localCertificateAuthority;
                hasPathLengthConstraint = localHasPathLengthConstraint;
                pathLengthConstraint    = localPathLengthConstraint;
            }
        }
Esempio n. 2
0
 public void DecodeX509BasicConstraintsExtension(byte[] encoded, out bool certificateAuthority, out bool hasPathLengthConstraint, out int pathLengthConstraint)
 {
     unsafe
     {
         (certificateAuthority, hasPathLengthConstraint, pathLengthConstraint) = encoded.DecodeObject(
             CryptDecodeObjectStructType.X509_BASIC_CONSTRAINTS,
             static delegate(void *pvDecoded, int cbDecoded)
         {
             Debug.Assert(cbDecoded >= sizeof(CERT_BASIC_CONSTRAINTS_INFO));
             CERT_BASIC_CONSTRAINTS_INFO *pBasicConstraints = (CERT_BASIC_CONSTRAINTS_INFO *)pvDecoded;
             return((Marshal.ReadByte(pBasicConstraints->SubjectType.pbData) & CERT_BASIC_CONSTRAINTS_INFO.CERT_CA_SUBJECT_FLAG) != 0,
                    pBasicConstraints->fPathLenConstraint != 0,
                    pBasicConstraints->dwPathLenConstraint);
         });
     }
 }