/// <summary></summary> private void Initialise() { _iDBits = _iPBits = _iQBits = _iInverseQBits = _iOffsetSecretKey = 0; _eStringToKeyUsage = nStringToKeyUsage.Sha1; _eSymmetricKeyAlgorithm = nSymmetricKeyAlgorithm.Aes128; _eStringToKeySpecifier = nStringToKeySpecifier.SaltedAndIterated; _eHashAlgorithm = nHashAlgorithm.Sha1; _Cryptography = null; _PublicKey = null; _KeyParameters = new RSAParameters(); }
/// <summary></summary> public PgpPrivateKey(PgpPacket FromPacket, EncryptionServices Cryptography) : base(FromPacket) { PgpPublicKeyUtility KeyUtility; Initialise(); _Cryptography = Cryptography; KeyUtility = new PgpPublicKeyUtility(_abRawBytes); // extract the public key bytes _eStatus = KeyUtility.eStatus; if (_eStatus == nStatus.OK) { _PublicKey = new PgpPublicKey(new PgpPacket(KeyUtility.abRawBytes, 0)); // and turn them into a public key _KeyParameters.Exponent = KeyUtility.abExponent; _KeyParameters.Modulus = KeyUtility.abModulus; _eStatus = _PublicKey.eStatus; if (_eStatus == nStatus.OK) { _iOffsetSecretKey = _PublicKey.iHeaderLength + _PublicKey.iDataLength; _eStringToKeyUsage = (nStringToKeyUsage)_abRawBytes[_iOffsetSecretKey++]; if ((_eStringToKeyUsage == nStringToKeyUsage.Sha1) || (_eStringToKeyUsage == nStringToKeyUsage.Checksum)) { _eSymmetricKeyAlgorithm = (nSymmetricKeyAlgorithm)_abRawBytes[_iOffsetSecretKey++]; _eStringToKeySpecifier = (nStringToKeySpecifier)_abRawBytes[_iOffsetSecretKey++]; _eHashAlgorithm = (nHashAlgorithm)_abRawBytes[_iOffsetSecretKey++]; if ((_eSymmetricKeyAlgorithm == nSymmetricKeyAlgorithm.Unencrypted) || (_eSymmetricKeyAlgorithm == nSymmetricKeyAlgorithm.Aes128)) { if (_eStringToKeySpecifier == nStringToKeySpecifier.GnuDummy) { throw new NotImplementedException("eStringToKeySpecifier == nStringToKeySpecifier.GnuDummy"); } } else { _eStatus = nStatus.AlgorithmNotSupported; } } else { _eStatus = nStatus.AlgorithmNotSupported; } } } }