/// <summary>
 /// Construct a version 4 public key packet.
 /// </summary>
 /// <param name="algorithm">The algorithm.</param>
 /// <param name="time">The time.</param>
 /// <param name="key">The key.</param>
 public PublicKeyPacket(PublicKeyAlgorithmTag algorithm, DateTime time, IBcpgPublicKey key)
 {
     _version   = 4;
     _time      = DateTimeUtilities.DateTimeToUnixMs(time) / 1000L;
     _algorithm = algorithm;
     _key       = key;
 }
 /// <summary>
 /// Construct a version 4 public key packet.
 /// </summary>
 /// <param name="algorithm">The algorithm.</param>
 /// <param name="time">The time.</param>
 /// <param name="key">The key.</param>
 public PublicKeyPacket(PublicKeyAlgorithmTag algorithm, DateTime time, IBcpgPublicKey key)
 {
     _version = 4;
     _time = DateTimeUtilities.DateTimeToUnixMs(time) / 1000L;
     _algorithm = algorithm;
     _key = key;
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="PublicKeyPacket"/> class.
        /// </summary>
        /// <param name="bcpgIn">The BCPG in.</param>
        /// <exception cref="System.IO.IOException">unknown PGP public key algorithm encountered</exception>
        internal PublicKeyPacket(BcpgInputStream bcpgIn)
        {
            _version = bcpgIn.ReadByte();

            _time = ((uint)bcpgIn.ReadByte() << 24) | ((uint)bcpgIn.ReadByte() << 16)
                    | ((uint)bcpgIn.ReadByte() << 8) | (uint)bcpgIn.ReadByte();

            if (_version <= 3)
            {
                _validDays = (bcpgIn.ReadByte() << 8) | bcpgIn.ReadByte();
            }

            _algorithm = (PublicKeyAlgorithmTag)bcpgIn.ReadByte();

            switch (_algorithm)
            {
            case PublicKeyAlgorithmTag.RsaEncrypt:
            case PublicKeyAlgorithmTag.RsaGeneral:
            case PublicKeyAlgorithmTag.RsaSign:
                _key = new RsaPublicBcpgKey(bcpgIn);
                break;

            case PublicKeyAlgorithmTag.Dsa:
                _key = new DsaPublicBcpgKey(bcpgIn);
                break;

            case PublicKeyAlgorithmTag.ElGamalEncrypt:
            case PublicKeyAlgorithmTag.ElGamalGeneral:
                _key = new ElGamalPublicBcpgKey(bcpgIn);
                break;

            case PublicKeyAlgorithmTag.Ecdh:
                _key = new ECDHPublicBcpgKey(bcpgIn);
                break;

            case PublicKeyAlgorithmTag.Ecdsa:
                _key = new ECDSAPublicBcpgKey(bcpgIn);
                break;

            default:
                throw new IOException("unknown PGP public key algorithm encountered");
            }
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="PublicKeyPacket"/> class.
        /// </summary>
        /// <param name="bcpgIn">The BCPG in.</param>
        /// <exception cref="System.IO.IOException">unknown PGP public key algorithm encountered</exception>
        internal PublicKeyPacket(BcpgInputStream bcpgIn)
        {
            _version = bcpgIn.ReadByte();

            _time = ((uint)bcpgIn.ReadByte() << 24) | ((uint)bcpgIn.ReadByte() << 16)
                | ((uint)bcpgIn.ReadByte() << 8) | (uint)bcpgIn.ReadByte();

            if (_version <= 3)
            {
                _validDays = (bcpgIn.ReadByte() << 8) | bcpgIn.ReadByte();
            }

            _algorithm = (PublicKeyAlgorithmTag)bcpgIn.ReadByte();

            switch (_algorithm)
            {
                case PublicKeyAlgorithmTag.RsaEncrypt:
                case PublicKeyAlgorithmTag.RsaGeneral:
                case PublicKeyAlgorithmTag.RsaSign:
                    _key = new RsaPublicBcpgKey(bcpgIn);
                    break;
                case PublicKeyAlgorithmTag.Dsa:
                    _key = new DsaPublicBcpgKey(bcpgIn);
                    break;
                case PublicKeyAlgorithmTag.ElGamalEncrypt:
                case PublicKeyAlgorithmTag.ElGamalGeneral:
                    _key = new ElGamalPublicBcpgKey(bcpgIn);
                    break;

                case PublicKeyAlgorithmTag.Ecdh:
                    _key = new ECDHPublicBcpgKey(bcpgIn);
                    break;
                case PublicKeyAlgorithmTag.Ecdsa:
                    _key = new ECDSAPublicBcpgKey(bcpgIn);
                    break;

                default:
                    throw new IOException("unknown PGP public key algorithm encountered");
            }
        }
 /// <summary>Construct a version 4 public subkey packet.</summary>
 public PublicSubkeyPacket(PublicKeyAlgorithmTag algorithm, DateTime time, IBcpgPublicKey key)
     : base(algorithm, time, key)
 {
 }
 /// <summary>Construct a version 4 public subkey packet.</summary>
 public PublicSubkeyPacket(PublicKeyAlgorithmTag algorithm, DateTime time, IBcpgPublicKey key)
     : base(algorithm, time, key)
 {
 }