org.silverpeas.util.crypto
Class CMSCipher

java.lang.Object
  extended by org.silverpeas.util.crypto.CMSCipher
All Implemented Interfaces:
Cipher

public class CMSCipher
extends Object
implements Cipher

The Cryptographic Message Syntax (CMS) is the IETF's standard for cryptographically protected messages. It can be used to digitally sign, digest, authenticate or encrypt any form of digital data. It is based on the syntax of PKCS#7, which in turn is based on the Privacy-Enhanced Mail standard. The newest version of CMS (as of 2009) is specified in RFC 5652 (but see also RFC 5911 for updated ASN.1 modules conforming to ASN.1 2002).

The architecture of CMS is built around certificate-based key management, such as the profile defined by the PKIX working group.

CMS is used as the key cryptographic component of many other cryptographic standards, such as S/MIME, PKCS#12 and the RFC 3161 Digital timestamping protocol.

This implementation wraps the all the mechanism required to encrypt and to decrypt messages within a PKS/CMS infrastructure. For doing it uses the public key, the secret key and the X509 certificate provided by a PKS#12 key store (an instance of the PKS12KeyStore class).

Instances of this class is for signing and encrypting, and checking and decrypting data exchanged between two interlocutors.


Constructor Summary
protected CMSCipher()
           
 
Method Summary
 String decrypt(byte[] encryptedData, CipherKey keyFilePath)
          Decrypt the specified code or cipher by using the specified cryptographic key.
 byte[] encrypt(String data, CipherKey keyFilePath)
          Encrypts the specified data by using the specified cryptographic key.
 CipherKey generateCipherKey()
          This operation isn't yet supported by this cipher.
 CryptographicAlgorithmName getAlgorithmName()
          Gets the name of the algorithm of the cipher.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CMSCipher

protected CMSCipher()
Method Detail

getAlgorithmName

public CryptographicAlgorithmName getAlgorithmName()
Gets the name of the algorithm of the cipher.

Specified by:
getAlgorithmName in interface Cipher
Returns:
the algorithm name.

encrypt

public byte[] encrypt(String data,
                      CipherKey keyFilePath)
               throws CryptoException
Encrypts the specified data by using the specified cryptographic key.

The String objects handled by the encryption is done according the UTF-8 charset.

Specified by:
encrypt in interface Cipher
Parameters:
data - the data to encode.
keyFilePath - the file in which is stored the public key to use in the encryption.
Returns:
the encrypted data in bytes.
Throws:
CryptoException - if an error has occurred in the data encryption.

decrypt

public String decrypt(byte[] encryptedData,
                      CipherKey keyFilePath)
               throws CryptoException
Decrypt the specified code or cipher by using the specified cryptographic key.

The String objects handled by the encryption is done according the UTF-8 charset.

Specified by:
decrypt in interface Cipher
Parameters:
encryptedData - the data in bytes that was encrypted by this cipher.
keyFilePath - the file in which is stored the secret key to use in the decryption.
Returns:
the decrypted data.
Throws:
CryptoException - if an error has occurred in the data decryption.

generateCipherKey

public CipherKey generateCipherKey()
                            throws CryptoException
This operation isn't yet supported by this cipher.

Specified by:
generateCipherKey in interface Cipher
Returns:
nothing, throws an UnsupportedOperationException exception.
Throws:
CryptoException - if an error has occurred in the key generation.


Copyright © 2016 Silverpeas. All Rights Reserved.