/// <summary>
        /// Gets the signing stream.
        /// </summary>
        /// <returns></returns>
        public HashingStream GetSigningStream(Keyczar keyczar)
        {
            var signer = PublicKey.GetSigner();

            signer.Init(forSigning: true, parameters: new RsaPrivateCrtKeyParameters(
                            Utility.ToBouncyBigInteger(PublicKey.Modulus),
                            Utility.ToBouncyBigInteger(PublicKey.PublicExponent),
                            PrivateExponent.ToBouncyBigInteger(),
                            PrimeP.ToBouncyBigInteger(),
                            PrimeQ.ToBouncyBigInteger(),
                            PrimeExponentP.ToBouncyBigInteger(),
                            PrimeExponentQ.ToBouncyBigInteger(),
                            CrtCoefficient.ToBouncyBigInteger()));

            return(new DigestStream(signer, Size / 8));
        }
Exemple #2
0
        /// <summary>
        /// Gets the decrypting stream.
        /// </summary>
        /// <param name="output">The output.</param>
        /// <returns></returns>
        public FinishingStream GetDecryptingStream(Stream output, Keyczar keyczar)
        {
            var rsa  = new RsaEngine();
            var oaep = PublicKey.UpdatePadding(rsa);

            return(new AsymmetricStream(oaep, output,
                                        (cipher, encrypt) => cipher.Init(encrypt, new RsaPrivateCrtKeyParameters(
                                                                             PublicKey.Modulus
                                                                             .ToBouncyBigInteger(),
                                                                             PublicKey.PublicExponent
                                                                             .ToBouncyBigInteger(),
                                                                             PrivateExponent.ToBouncyBigInteger
                                                                                 (),
                                                                             PrimeP.ToBouncyBigInteger(),
                                                                             PrimeQ.ToBouncyBigInteger(),
                                                                             PrimeExponentP.ToBouncyBigInteger(),
                                                                             PrimeExponentQ.ToBouncyBigInteger(),
                                                                             CrtCoefficient.ToBouncyBigInteger())),
                                        encrypt: false));
        }