Class RSASession


  • public class RSASession
    extends java.lang.Object
    This class is necessitated by the fact that the new GSI protocol requires encryption and decryption of the arbitrarily long Diffie-Hellman encoded parameters. RSA encryption/decryption is not recommended for block-like processing of messages, but this is the way that the SLAC client and server do it, so we are constrained to follow suit.
    • Constructor Summary

      Constructors 
      Constructor Description
      RSASession()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      byte[] decrypt​(byte[] in)  
      byte[] encrypt​(byte[] in)  
      void initializeForDecryption​(java.security.PublicKey publicKey)
      Prepare rsaCipher for decryption using received public key.
      void initializeForEncryption​(java.security.PrivateKey privateKey)
      Prepare rsaCipher for encryption using local private key.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • LOGGER

        protected static org.slf4j.Logger LOGGER
      • cipher

        protected javax.crypto.Cipher cipher
      • maxDecryptionBlockSize

        protected int maxDecryptionBlockSize
      • maxEncryptionBlockSize

        protected int maxEncryptionBlockSize
    • Constructor Detail

      • RSASession

        public RSASession()
    • Method Detail

      • initializeForEncryption

        public void initializeForEncryption​(java.security.PrivateKey privateKey)
                                     throws javax.crypto.NoSuchPaddingException,
                                            java.security.NoSuchAlgorithmException,
                                            java.security.NoSuchProviderException,
                                            java.security.InvalidKeyException
        Prepare rsaCipher for encryption using local private key.
        Throws:
        javax.crypto.NoSuchPaddingException
        java.security.NoSuchAlgorithmException
        java.security.NoSuchProviderException
        java.security.InvalidKeyException
      • initializeForDecryption

        public void initializeForDecryption​(java.security.PublicKey publicKey)
                                     throws javax.crypto.NoSuchPaddingException,
                                            java.security.NoSuchAlgorithmException,
                                            java.security.NoSuchProviderException,
                                            java.security.InvalidKeyException
        Prepare rsaCipher for decryption using received public key.
        Throws:
        javax.crypto.NoSuchPaddingException
        java.security.NoSuchAlgorithmException
        java.security.NoSuchProviderException
        java.security.InvalidKeyException
      • encrypt

        public byte[] encrypt​(byte[] in)
                       throws java.io.IOException,
                              javax.crypto.BadPaddingException,
                              javax.crypto.IllegalBlockSizeException
        Throws:
        java.io.IOException
        javax.crypto.BadPaddingException
        javax.crypto.IllegalBlockSizeException
      • decrypt

        public byte[] decrypt​(byte[] in)
                       throws java.io.IOException,
                              javax.crypto.BadPaddingException,
                              javax.crypto.IllegalBlockSizeException
        Throws:
        java.io.IOException
        javax.crypto.BadPaddingException
        javax.crypto.IllegalBlockSizeException