/// <summary> /// Gets the verifying stream. /// </summary> /// <returns></returns> public VerifyingStream GetVerifyingStream(Keyczar keyczar) { var hmac = new HMac(new Sha1Digest()); hmac.Init(new KeyParameter(HmacKeyBytes)); return(new HmacStream(hmac)); }
public override FinishingStream GetDecryptingStream(Stream output, Keyczar keyczar) { var stream = (CipherTextOnlyFinishingStream)base.GetDecryptingStream(output, keyczar); stream.CipherTextOnly = true; stream.IV = IV; return(stream); }
/// <summary> /// Gets the verifying stream. /// </summary> /// <returns></returns> public VerifyingStream GetVerifyingStream(Keyczar keyczar) { var signer = GetSigner(); signer.Init(forSigning: false, parameters: new RsaKeyParameters(false, Modulus.ToBouncyBigInteger(), PublicExponent.ToBouncyBigInteger())); return(new DigestStream(signer, Size / 8)); }
/// <summary> /// Gets the decrypting stream. /// </summary> /// <param name="output">The output.</param> /// <returns></returns> public virtual FinishingStream GetDecryptingStream(Stream output, Keyczar keyczar) { return(new SymmetricStream( new PaddedBufferedBlockCipher(new CbcBlockCipher(new AesEngine()), new Pkcs7Padding()), output, new byte[BlockLength], HmacKey.Maybe(it => it.HashLength, () => 0), (iv, cipher, encrypt) => cipher.Init(forEncryption: encrypt, parameters: new ParametersWithIV(new KeyParameter(AesKeyBytes), iv)), encrypt: false)); }
/// <summary> /// Gets the decrypting stream. /// </summary> /// <param name="output">The output.</param> /// <returns></returns> public FinishingStream GetDecryptingStream(Stream output, Keyczar keyczar) { return(new SymmetricAeadStream( GetMode(), output, new byte[IVLength], TagLength, (nonce, cipher, additionalData, encrypt) => cipher.Init(encrypt, new AeadParameters(GetKeyParameters(), TagLength * 8, nonce, additionalData)), encrypt: false )); }
/// <summary> /// Gets the signing stream. /// </summary> /// <returns></returns> public HashingStream GetSigningStream(Keyczar keyczar) { var digest = PublicKey.GetDigest(); var signer = new DsaDigestSigner(new DsaSigner(), digest); var param = new DsaPrivateKeyParameters(X.ToBouncyBigInteger(), new DsaParameters(PublicKey.P.ToBouncyBigInteger(), PublicKey.Q.ToBouncyBigInteger(), PublicKey.G.ToBouncyBigInteger())); signer.Init(forSigning: true, parameters: new ParametersWithRandom(param, Secure.Random)); return(new DigestStream(signer)); }
/// <summary> /// Gets the encrypting stream. /// </summary> /// <param name="output">The output.</param> /// <returns></returns> public FinishingStream GetEncryptingStream(Stream output, Keyczar keyczar) { var rsa = new RsaEngine(); var oaep = UpdatePadding(rsa); return(new AsymmetricStream( oaep, output, (cipher, encrypt) => cipher.Init(encrypt, new RsaKeyParameters(false, Modulus.ToBouncyBigInteger(), PublicExponent.ToBouncyBigInteger())), encrypt: true)); }
/// <summary> /// Gets the encrypting stream. /// </summary> /// <param name="output">The output.</param> /// <returns></returns> public FinishingStream GetEncryptingStream(Stream output, Keyczar keyczar) { var randomNonce = new byte[IVLength]; Secure.Random.NextBytes(randomNonce); return(new SymmetricAeadStream( GetMode(), output, randomNonce, TagLength, (nonce, cipher, authdata, encrypt) => cipher.Init(encrypt, new AeadParameters(GetKeyParameters(), TagLength * 8, nonce, authdata)), encrypt: true )); }
/// <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)); }
/// <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)); }
/// <summary> /// Gets the verifying stream. /// </summary> /// <returns></returns> public VerifyingStream GetVerifyingStream(Keyczar keyczar) { var tSigner = new DsaSigner(); tSigner.Init(forSigning: false, parameters: new DsaPublicKeyParameters(Y.ToBouncyBigInteger(), new DsaParameters( P.ToBouncyBigInteger(), Q.ToBouncyBigInteger(), G.ToBouncyBigInteger()))); var digest = GetDigest(); var signer = new DsaDigestSigner(tSigner, digest); return(new DigestStream(new DsaDigestSigner(tSigner, digest), sigRepair: sig => { if (!keyczar.Config.StrictDsaVerification) { return Utility.RemoveJunkFronAnsiObj(sig); } return sig; })); }
/// <summary> /// Gets the encrypting stream. /// </summary> /// <param name="output">The output.</param> /// <returns></returns> public FinishingStream GetEncryptingStream(Stream output, Keyczar keyczar) { return(PublicKey.GetEncryptingStream(output, keyczar)); }
/// <summary> /// Gets the verifying stream. /// </summary> /// <returns></returns> public VerifyingStream GetVerifyingStream(Keyczar keyczar) { return(PublicKey.GetVerifyingStream(keyczar)); }
/// <summary> /// Gets the authentication signing stream. /// </summary> /// <returns></returns> public HashingStream GetAuthSigningStream(Keyczar keyczar) { return(HmacKey.Maybe(h => h.GetSigningStream(keyczar), () => null)); }
/// <summary> /// Gets the authentication verifying stream. /// </summary> /// <returns></returns> public VerifyingStream GetAuthVerifyingStream(Keyczar keyczar) { return(HmacKey.Maybe(h => h.GetVerifyingStream(keyczar), () => null)); }
/// <summary> /// Gets the authentication verifying stream. /// </summary> /// <returns>null as authentication is built in to the decryption</returns> public VerifyingStream GetAuthVerifyingStream(Keyczar keyczar) { return(null); //One stop verifying and decrypting }
/// <summary> /// Gets the authentication signing stream. /// </summary> /// <returns>null as authentication is built in to the encryption</returns> public HashingStream GetAuthSigningStream(Keyczar keyczar) { return(null); //One stop encrypting and signing; }
/// <summary> /// Gets the signing stream. /// </summary> /// <returns></returns> public HashingStream GetSigningStream(Keyczar keyczar) { return(GetVerifyingStream(keyczar)); }
/// <summary> /// Gets the authentication signing stream. /// </summary> /// <returns>null</returns> public HashingStream GetAuthSigningStream(Keyczar keyczar) { return(null); //not signed }
/// <summary> /// Gets the authentication verifying stream. /// </summary> /// <returns>null</returns> public VerifyingStream GetAuthVerifyingStream(Keyczar keyczar) { return(null); //not signed }