/* * [DecryptAndVerify.java] * * Summary: Decrypt a message and verify the digital signature. * * Copyright: (c) 2004-2017 Roedy Green, Canadian Mind Products, http://mindprod.com * * Licence: This software may be copied and used freely for any purpose but military. * http://mindprod.com/contact/nonmil.html * * Requires: JDK 1.8+ * * Created with: JetBrains IntelliJ IDEA IDE http://www.jetbrains.com/idea/ * * Version History: * 1.4 2006-03-05 reformat with IntelliJ and add Javadoc. */ package com.mindprod.transporter; import java.io.IOException; import java.io.Serializable; /** * Decrypt a message and verify the digital signature. *

* Uses compression, and base64u armouring. * See Transporter.java for example of use. * * @author Roedy Green, Canadian Mind Products * @version 1.4 2006-03-05 reformat with IntelliJ and add Javadoc. * @since 2004-06-08 */ public final class DecryptAndVerify extends Unwrap { /** * helper for decrypting */ private final Decrypt decrypter; /** * helper for verifying */ private final Verify verifier; /** * constructor. * * @param receiverPrivateKey Receiver's private key * @param senderPublicKey sender's public key (one who signed message). */ public DecryptAndVerify( PrivateKey receiverPrivateKey, PublicKey senderPublicKey ) { super(); decrypter = new Decrypt( receiverPrivateKey ); verifier = new Verify( senderPublicKey ); } /** * Unwraps encrypted, signed object sent via CIA Post, using serialiasation, compression, signing, encryption and * base64u armouring. Does not build parm=value. * * @param s base64u string to analyse * * @return reconstituted object * @throws IOException if signature validation fails. */ public Serializable unwrap( String s ) throws IOException { return reconstitute( decompress( verifier.verify( decrypter .decrypt( disarmour( s ) ) ) ) ); } } // end DecryptAndVerify