FromCapiPublicKeyBlob() static private method

static private FromCapiPublicKeyBlob ( byte blob, int offset ) : RSA
blob byte
offset int
return System.Security.Cryptography.RSA
示例#1
0
        public static RSA FromCapiKeyBlob(byte[] blob, int offset)
        {
            if (blob == null)
            {
                throw new ArgumentNullException("blob");
            }
            if (offset >= blob.Length)
            {
                throw new ArgumentException("blob is too small.");
            }
            byte b = blob[offset];

            if (b == 6)
            {
                return(CryptoConvert.FromCapiPublicKeyBlob(blob, offset));
            }
            if (b != 7)
            {
                if (b == 0)
                {
                    if (blob[offset + 12] == 6)
                    {
                        return(CryptoConvert.FromCapiPublicKeyBlob(blob, offset + 12));
                    }
                }
                throw new CryptographicException("Unknown blob format.");
            }
            return(CryptoConvert.FromCapiPrivateKeyBlob(blob, offset));
        }
示例#2
0
        public static RSA FromCapiKeyBlob(byte[] blob, int offset)
        {
            if (blob == null)
            {
                throw new ArgumentNullException(nameof(blob));
            }
            if (offset >= blob.Length)
            {
                throw new ArgumentException("blob is too small.");
            }
            switch (blob[offset])
            {
            case 0:
                if (blob[offset + 12] == (byte)6)
                {
                    return(CryptoConvert.FromCapiPublicKeyBlob(blob, offset + 12));
                }
                break;

            case 6:
                return(CryptoConvert.FromCapiPublicKeyBlob(blob, offset));

            case 7:
                return(CryptoConvert.FromCapiPrivateKeyBlob(blob, offset));
            }
            throw new CryptographicException("Unknown blob format.");
        }
示例#3
0
 public static RSA FromCapiPublicKeyBlob(byte[] blob)
 {
     return(CryptoConvert.FromCapiPublicKeyBlob(blob, 0));
 }