示例#1
0
        public void ReadFromTpmBlob(TPMBlob blob)
        {
            _algorithmId = (TPMAlgorithmId)blob.ReadUInt32();
            _encScheme   = (TPMEncScheme)blob.ReadUInt16();
            _sigScheme   = (TPMSigScheme)blob.ReadUInt16();

            UInt32 paramsSize = blob.ReadUInt32();

            byte[] paramsData = new byte[paramsSize];

            blob.Read(paramsData, 0, paramsData.Length);

            using (TPMBlob paramSrc = new TPMBlob(paramsData))
            {
                if (_algorithmId == TPMAlgorithmId.TPM_ALG_RSA)
                {
                    _params = TPMRSAKeyParamsCore.CreateFromTPMBlob(paramSrc);
                }
                else if (_algorithmId == TPMAlgorithmId.TPM_ALG_AES128 ||
                         _algorithmId == TPMAlgorithmId.TPM_ALG_AES192 ||
                         _algorithmId == TPMAlgorithmId.TPM_ALG_AES256)
                {
                    //TODO
                    throw new NotImplementedException("Symmetric key params not implemented");
                }
            }
        }
示例#2
0
        public static TPMRSAKeyParamsCore CreateFromTPMBlob(TPMBlob blob)
        {
            TPMRSAKeyParamsCore keyParams = new TPMRSAKeyParamsCore();

            keyParams.ReadFromTpmBlob(blob);
            return(keyParams);
        }
示例#3
0
        public static TPMRSAKeyParamsCore Create(uint keyLength, uint numPrimes, byte[] exponent)
        {
            TPMRSAKeyParamsCore rsaKeyParams = new TPMRSAKeyParamsCore();

            rsaKeyParams._keyLength = keyLength;

            if (numPrimes == 0)
            {
                rsaKeyParams._numPrimes = DEFAULT_NUMPRIMES;
            }
            else
            {
                rsaKeyParams._numPrimes = numPrimes;
            }

            if (exponent == null)
            {
                rsaKeyParams._exponent = new byte[0];
            }
            else
            {
                rsaKeyParams._exponent = exponent;
            }

            return(rsaKeyParams);
        }
示例#4
0
        public static TPMRSAKeyParamsCore Create(uint keyLength, uint numPrimes, byte[] exponent)
        {
            TPMRSAKeyParamsCore rsaKeyParams = new TPMRSAKeyParamsCore ();
            rsaKeyParams._keyLength = keyLength;

            if(numPrimes == 0)
                rsaKeyParams._numPrimes = DEFAULT_NUMPRIMES;
            else
                rsaKeyParams._numPrimes = numPrimes;

            if (exponent == null)
                rsaKeyParams._exponent = new byte[0];
            else
                rsaKeyParams._exponent = exponent;

            return rsaKeyParams;
        }
示例#5
0
 public static TPMRSAKeyParamsCore CreateFromTPMBlob(TPMBlob blob)
 {
     TPMRSAKeyParamsCore keyParams = new TPMRSAKeyParamsCore();
     keyParams.ReadFromTpmBlob(blob);
     return keyParams;
 }