Class Encryptor


  • public class Encryptor
    extends java.lang.Object
    Encrypts data with the SecretDecoderRing.
    • Constructor Summary

      Constructors 
      Constructor Description
      Encryptor​(CryptoToken token, byte[] keyID, EncryptionAlgorithm alg)
      Creates an Encryptor on the given CryptoToken, using the key with the given keyID and algorithm
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      byte[] encrypt​(byte[] plaintext)
      Encrypts a byte array.
      • Methods inherited from class java.lang.Object

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

      • DEFAULT_ENCRYPTION_ALG

        public static final EncryptionAlgorithm DEFAULT_ENCRYPTION_ALG
        The default encryption algorithm, currently DES3_CBC.
    • Constructor Detail

      • Encryptor

        public Encryptor​(CryptoToken token,
                         byte[] keyID,
                         EncryptionAlgorithm alg)
                  throws TokenException,
                         java.security.InvalidKeyException
        Creates an Encryptor on the given CryptoToken, using the key with the given keyID and algorithm
        Parameters:
        token - The CryptoToken to use for encryption. The key must reside on this token.
        keyID - The keyID of the key to use for encryption. This key must have been generated on this token with KeyManager.
        alg - The EncryptionAlgorithm this key will be used for.
        Throws:
        java.security.InvalidKeyException - If no key exists on this token with this keyID.
        TokenException
    • Method Detail

      • encrypt

        public byte[] encrypt​(byte[] plaintext)
                       throws NotInitializedException,
                              java.security.GeneralSecurityException,
                              InvalidBERException
        Encrypts a byte array.
        Parameters:
        plaintext - The plaintext bytes to be encrypted.
        Returns:
        The ciphertext. This is actually a DER-encoded Encoding object. It contains the keyID, AlgorithmIdentifier, and the encrypted plaintext. It is compatible with the SDRResult created by NSS's SecretDecoderRing.
        Throws:
        NotInitializedException
        java.security.GeneralSecurityException
        InvalidBERException