internal static byte[] DecodeOctetBytes(byte[] encodedOctetString) { uint cbDecodedValue = 0U; SafeLocalAllocHandle decodedValue = (SafeLocalAllocHandle)null; if (!CAPI.DecodeObject(new IntPtr(25L), encodedOctetString, out decodedValue, out cbDecodedValue)) { throw new CryptographicException(Marshal.GetLastWin32Error()); } if ((int)cbDecodedValue == 0) { return(new byte[0]); } using (decodedValue) return(CAPI.BlobToByteArray(decodedValue.DangerousGetHandle())); }
private void DecodeExtension() { uint cbDecodedValue = 0; SafeLocalAllocHandle decodedValue = null; SafeLocalAllocHandle handle2 = System.Security.Cryptography.X509Certificates.X509Utils.StringToAnsiPtr("2.5.29.14"); if (!CAPI.DecodeObject(handle2.DangerousGetHandle(), base.m_rawData, out decodedValue, out cbDecodedValue)) { throw new CryptographicException(Marshal.GetLastWin32Error()); } CAPIBase.CRYPTOAPI_BLOB blob = (CAPIBase.CRYPTOAPI_BLOB)Marshal.PtrToStructure(decodedValue.DangerousGetHandle(), typeof(CAPIBase.CRYPTOAPI_BLOB)); byte[] sArray = CAPI.BlobToByteArray(blob); this.m_subjectKeyIdentifier = System.Security.Cryptography.X509Certificates.X509Utils.EncodeHexString(sArray); this.m_decoded = true; decodedValue.Dispose(); handle2.Dispose(); }
private void DecodeExtension() { uint cbDecoded = 0; SafeLocalAllocHandle decoded = null; SafeLocalAllocHandle pb = X509Utils.StringToAnsiPtr(CAPI.szOID_SUBJECT_KEY_IDENTIFIER); bool result = CAPI.DecodeObject(pb.DangerousGetHandle(), m_rawData, out decoded, out cbDecoded); if (!result) { throw new CryptographicException(Marshal.GetLastWin32Error()); } CAPI.CRYPTOAPI_BLOB pSubjectKeyIdentifier = (CAPI.CRYPTOAPI_BLOB)Marshal.PtrToStructure(decoded.DangerousGetHandle(), typeof(CAPI.CRYPTOAPI_BLOB)); byte[] hexArray = CAPI.BlobToByteArray(pSubjectKeyIdentifier); m_subjectKeyIdentifier = X509Utils.EncodeHexString(hexArray); m_decoded = true; decoded.Dispose(); pb.Dispose(); }
internal static AsnEncodedDataCollection GetAsnEncodedDataCollection(CAPI.CRYPT_ATTRIBUTE_TYPE_VALUE cryptAttribute) { return(new AsnEncodedDataCollection() { (AsnEncodedData) new Pkcs9AttributeObject(new Oid(cryptAttribute.pszObjId), CAPI.BlobToByteArray(cryptAttribute.Value)) }); }
internal static AsnEncodedDataCollection GetAsnEncodedDataCollection(CAPI.CRYPT_ATTRIBUTE cryptAttribute) { AsnEncodedDataCollection encodedDataCollection = new AsnEncodedDataCollection(); Oid oid = new Oid(cryptAttribute.pszObjId); string name = oid.Value; for (uint index = 0U; index < cryptAttribute.cValue; ++index) { IntPtr pBlob = new IntPtr((long)cryptAttribute.rgValue + (long)index * (long)Marshal.SizeOf(typeof(CAPI.CRYPTOAPI_BLOB))); Pkcs9AttributeObject pkcs9AttributeObject1 = new Pkcs9AttributeObject(oid, CAPI.BlobToByteArray(pBlob)); Pkcs9AttributeObject pkcs9AttributeObject2 = CryptoConfig.CreateFromName(name) as Pkcs9AttributeObject; if (pkcs9AttributeObject2 != null) { pkcs9AttributeObject2.CopyFrom((AsnEncodedData)pkcs9AttributeObject1); pkcs9AttributeObject1 = pkcs9AttributeObject2; } encodedDataCollection.Add((AsnEncodedData)pkcs9AttributeObject1); } return(encodedDataCollection); }