예제 #1
0
 internal PublicKeyInfo(CAPI.CERT_PUBLIC_KEY_INFO keyInfo)
 {
     m_algorithm = new AlgorithmIdentifier(keyInfo);
     m_keyValue  = new byte[keyInfo.PublicKey.cbData];
     if (m_keyValue.Length > 0)
     {
         Marshal.Copy(keyInfo.PublicKey.pbData, m_keyValue, 0, m_keyValue.Length);
     }
 }
예제 #2
0
 internal PublicKeyInfo(CAPI.CERT_PUBLIC_KEY_INFO keyInfo)
 {
     this.m_algorithm = new AlgorithmIdentifier(keyInfo);
     this.m_keyValue  = new byte[(IntPtr)keyInfo.PublicKey.cbData];
     if (this.m_keyValue.Length <= 0)
     {
         return;
     }
     Marshal.Copy(keyInfo.PublicKey.pbData, this.m_keyValue, 0, this.m_keyValue.Length);
 }
예제 #3
0
        internal AlgorithmIdentifier(CAPI.CERT_PUBLIC_KEY_INFO keyInfo)
        {
            SafeLocalAllocHandle pKeyInfo = CAPI.LocalAlloc(CAPI.LPTR, new IntPtr(Marshal.SizeOf(typeof(CAPI.CERT_PUBLIC_KEY_INFO))));

            Marshal.StructureToPtr(keyInfo, pKeyInfo.DangerousGetHandle(), false);
            int keyLength = (int)CAPI.CAPISafe.CertGetPublicKeyLength(CAPI.X509_ASN_ENCODING | CAPI.PKCS_7_ASN_ENCODING, pKeyInfo.DangerousGetHandle());

            byte[] parameters = new byte[keyInfo.Algorithm.Parameters.cbData];
            if (parameters.Length > 0)
            {
                Marshal.Copy(keyInfo.Algorithm.Parameters.pbData, parameters, 0, parameters.Length);
            }
            Marshal.DestroyStructure(pKeyInfo.DangerousGetHandle(), typeof(CAPI.CERT_PUBLIC_KEY_INFO));
            pKeyInfo.Dispose();
            Reset(Oid.FromOidValue(keyInfo.Algorithm.pszObjId, OidGroup.PublicKeyAlgorithm), keyLength, parameters);
        }
예제 #4
0
        internal AlgorithmIdentifier(CAPI.CERT_PUBLIC_KEY_INFO keyInfo)
        {
            SafeLocalAllocHandle localAllocHandle = CAPI.LocalAlloc(64U, new IntPtr(Marshal.SizeOf(typeof(CAPI.CERT_PUBLIC_KEY_INFO))));

            Marshal.StructureToPtr((object)keyInfo, localAllocHandle.DangerousGetHandle(), false);
            int keyLength = (int)CAPI.CAPISafe.CertGetPublicKeyLength(65537U, localAllocHandle.DangerousGetHandle());

            byte[] numArray = new byte[(IntPtr)keyInfo.Algorithm.Parameters.cbData];
            if (numArray.Length > 0)
            {
                Marshal.Copy(keyInfo.Algorithm.Parameters.pbData, numArray, 0, numArray.Length);
            }
            Marshal.DestroyStructure(localAllocHandle.DangerousGetHandle(), typeof(CAPI.CERT_PUBLIC_KEY_INFO));
            localAllocHandle.Dispose();
            this.Reset(new Oid(keyInfo.Algorithm.pszObjId), keyLength, numArray);
        }
예제 #5
0
 internal SubjectIdentifierOrKey(CAPI.CERT_PUBLIC_KEY_INFO publicKeyInfo)
 {
     Reset(SubjectIdentifierOrKeyType.PublicKeyInfo, new PublicKeyInfo(publicKeyInfo));
 }