FromCapiPrivateKeyBlob() static private method

static private FromCapiPrivateKeyBlob ( byte blob, int offset ) : RSA
blob byte
offset int
return System.Security.Cryptography.RSA
Example #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));
        }
Example #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.");
        }
Example #3
0
 public static RSA FromCapiPrivateKeyBlob(byte[] blob)
 {
     return(CryptoConvert.FromCapiPrivateKeyBlob(blob, 0));
 }