You are currently viewing a snapshot of www.mozilla.org taken on April 21, 2008. Most of this content is highly out of date (some pages haven't been updated since the project began in 1998) and exists for historical purposes only. If there are any pages on this archive site that you think should be added back to www.mozilla.org, please file a bug.




org.mozilla.jss.crypto
Class EncryptionAlgorithm

java.lang.Object
  extended by org.mozilla.jss.crypto.Algorithm
      extended by org.mozilla.jss.crypto.EncryptionAlgorithm

public class EncryptionAlgorithm
extends Algorithm

An algorithm for performing symmetric encryption.


Nested Class Summary
static class EncryptionAlgorithm.Alg
           
static class EncryptionAlgorithm.Mode
           
static class EncryptionAlgorithm.Padding
           
 
Field Summary
static EncryptionAlgorithm AES_128_CBC
           
static EncryptionAlgorithm AES_128_CBC_PAD
           
static EncryptionAlgorithm AES_128_ECB
           
static EncryptionAlgorithm AES_192_CBC
           
static EncryptionAlgorithm AES_192_CBC_PAD
           
static EncryptionAlgorithm AES_192_ECB
           
static EncryptionAlgorithm AES_256_CBC
           
static EncryptionAlgorithm AES_256_CBC_PAD
           
static EncryptionAlgorithm AES_256_ECB
           
static EncryptionAlgorithm AES_CBC_PAD
           
static OBJECT_IDENTIFIER AES_ROOT_OID
           
static EncryptionAlgorithm DES_CBC
           
static EncryptionAlgorithm DES_CBC_PAD
           
static EncryptionAlgorithm DES_ECB
           
static EncryptionAlgorithm DES3_CBC
           
static EncryptionAlgorithm DES3_CBC_PAD
           
static EncryptionAlgorithm DES3_ECB
           
static EncryptionAlgorithm RC2_CBC
           
static EncryptionAlgorithm RC2_CBC_PAD
           
static EncryptionAlgorithm RC4
           
 
Fields inherited from class org.mozilla.jss.crypto.Algorithm
CKM_AES_CBC, CKM_AES_CBC_PAD, CKM_AES_ECB, CKM_AES_KEY_GEN, CKM_DES_CBC_PAD, CKM_DES_KEY_GEN, CKM_DES3_CBC_PAD, CKM_DES3_ECB, CKM_DES3_KEY_GEN, CKM_DSA_KEY_PAIR_GEN, CKM_EC_KEY_PAIR_GEN, CKM_PBA_SHA1_WITH_SHA1_HMAC, CKM_RC2_CBC_PAD, CKM_RC2_KEY_GEN, CKM_RC4_KEY_GEN, CKM_RSA_PKCS_KEY_PAIR_GEN, CKM_SHA_1_HMAC, oid, oidIndex, SEC_OID_ANSIX9_DSA_SIGNATURE, SEC_OID_ANSIX9_DSA_SIGNATURE_WITH_SHA1_DIGEST, SEC_OID_ANSIX962_EC_PUBLIC_KEY, SEC_OID_ANSIX962_ECDSA_SHA1_SIGNATURE, SEC_OID_ANSIX962_ECDSA_SHA256_SIGNATURE, SEC_OID_ANSIX962_ECDSA_SHA384_SIGNATURE, SEC_OID_ANSIX962_ECDSA_SHA512_SIGNATURE, SEC_OID_DES_CBC, SEC_OID_DES_ECB, SEC_OID_DES_EDE3_CBC, SEC_OID_MD2, SEC_OID_MD5, SEC_OID_PKCS1_MD2_WITH_RSA_ENCRYPTION, SEC_OID_PKCS1_MD5_WITH_RSA_ENCRYPTION, SEC_OID_PKCS1_RSA_ENCRYPTION, SEC_OID_PKCS1_SHA1_WITH_RSA_ENCRYPTION, SEC_OID_PKCS1_SHA256_WITH_RSA_ENCRYPTION, SEC_OID_PKCS1_SHA384_WITH_RSA_ENCRYPTION, SEC_OID_PKCS1_SHA512_WITH_RSA_ENCRYPTION, SEC_OID_PKCS12_V2_PBE_WITH_SHA1_AND_128_BIT_RC2_CBC, SEC_OID_PKCS12_V2_PBE_WITH_SHA1_AND_128_BIT_RC4, SEC_OID_PKCS12_V2_PBE_WITH_SHA1_AND_3KEY_TRIPLE_DES_CBC, SEC_OID_PKCS12_V2_PBE_WITH_SHA1_AND_40_BIT_RC2_CBC, SEC_OID_PKCS12_V2_PBE_WITH_SHA1_AND_40_BIT_RC4, SEC_OID_PKCS5_PBE_WITH_MD2_AND_DES_CBC, SEC_OID_PKCS5_PBE_WITH_MD5_AND_DES_CBC, SEC_OID_PKCS5_PBE_WITH_SHA1_AND_DES_CBC, SEC_OID_RC2_CBC, SEC_OID_RC4, SEC_OID_SHA1, SEC_OID_SHA256, SEC_OID_SHA384, SEC_OID_SHA512
 
Constructor Summary
protected EncryptionAlgorithm(int oidTag, EncryptionAlgorithm.Alg alg, EncryptionAlgorithm.Mode mode, EncryptionAlgorithm.Padding padding, java.lang.Class[] paramClasses, int blockSize, OBJECT_IDENTIFIER oid, int keyStrength)
           
protected EncryptionAlgorithm(int oidTag, EncryptionAlgorithm.Alg alg, EncryptionAlgorithm.Mode mode, EncryptionAlgorithm.Padding padding, java.lang.Class paramClass, int blockSize, OBJECT_IDENTIFIER oid, int keyStrength)
           
 
Method Summary
static EncryptionAlgorithm fromOID(OBJECT_IDENTIFIER oid)
           
static EncryptionAlgorithm fromString(java.lang.String name)
          Deprecated. This method is deprecated because algorithm strings don't contain key length, which is necessary to distinguish between AES algorithms.
 EncryptionAlgorithm.Alg getAlg()
          Returns the base algorithm, without the parameters.
 int getBlockSize()
          The blocksize of the algorithm in bytes.
 int getIVLength()
          Returns the number of bytes that this algorithm expects in its initialization vector.
 int getKeyStrength()
          Returns the key strength of this algorithm in bits.
 EncryptionAlgorithm.Mode getMode()
          Returns the mode of this algorithm.
 EncryptionAlgorithm.Padding getPadding()
          Returns the padding type of this algorithm.
 EncryptionAlgorithm.Padding getPaddingType()
          Returns the type of padding for this algorithm.
 boolean isPadded()
          Deprecated. Call getPaddingType() instead.
static EncryptionAlgorithm lookup(java.lang.String algName, java.lang.String modeName, java.lang.String paddingName, int keyStrength)
           
 
Methods inherited from class org.mozilla.jss.crypto.Algorithm
getParameterClass, getParameterClasses, isValidParameterObject, toOID, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

RC4

public static final EncryptionAlgorithm RC4

DES_ECB

public static final EncryptionAlgorithm DES_ECB

DES_CBC

public static final EncryptionAlgorithm DES_CBC

DES_CBC_PAD

public static final EncryptionAlgorithm DES_CBC_PAD

DES3_ECB

public static final EncryptionAlgorithm DES3_ECB

DES3_CBC

public static final EncryptionAlgorithm DES3_CBC

DES3_CBC_PAD

public static final EncryptionAlgorithm DES3_CBC_PAD

RC2_CBC

public static final EncryptionAlgorithm RC2_CBC

RC2_CBC_PAD

public static final EncryptionAlgorithm RC2_CBC_PAD

AES_ROOT_OID

public static final OBJECT_IDENTIFIER AES_ROOT_OID

AES_128_ECB

public static final EncryptionAlgorithm AES_128_ECB

AES_128_CBC

public static final EncryptionAlgorithm AES_128_CBC

AES_128_CBC_PAD

public static final EncryptionAlgorithm AES_128_CBC_PAD

AES_192_ECB

public static final EncryptionAlgorithm AES_192_ECB

AES_192_CBC

public static final EncryptionAlgorithm AES_192_CBC

AES_192_CBC_PAD

public static final EncryptionAlgorithm AES_192_CBC_PAD

AES_256_ECB

public static final EncryptionAlgorithm AES_256_ECB

AES_256_CBC

public static final EncryptionAlgorithm AES_256_CBC

AES_CBC_PAD

public static final EncryptionAlgorithm AES_CBC_PAD

AES_256_CBC_PAD

public static final EncryptionAlgorithm AES_256_CBC_PAD
Constructor Detail

EncryptionAlgorithm

protected EncryptionAlgorithm(int oidTag,
                              EncryptionAlgorithm.Alg alg,
                              EncryptionAlgorithm.Mode mode,
                              EncryptionAlgorithm.Padding padding,
                              java.lang.Class paramClass,
                              int blockSize,
                              OBJECT_IDENTIFIER oid,
                              int keyStrength)

EncryptionAlgorithm

protected EncryptionAlgorithm(int oidTag,
                              EncryptionAlgorithm.Alg alg,
                              EncryptionAlgorithm.Mode mode,
                              EncryptionAlgorithm.Padding padding,
                              java.lang.Class[] paramClasses,
                              int blockSize,
                              OBJECT_IDENTIFIER oid,
                              int keyStrength)
Method Detail

getAlg

public EncryptionAlgorithm.Alg getAlg()
Returns the base algorithm, without the parameters. For example, the base algorithm of "AES/CBC/NoPadding" is "AES".


getMode

public EncryptionAlgorithm.Mode getMode()
Returns the mode of this algorithm.


getPadding

public EncryptionAlgorithm.Padding getPadding()
Returns the padding type of this algorithm.


getKeyStrength

public int getKeyStrength()
Returns the key strength of this algorithm in bits. Algorithms that use continuously variable key sizes (such as RC4) will return 0 to indicate they can use any key size.


fromOID

public static EncryptionAlgorithm fromOID(OBJECT_IDENTIFIER oid)
                                   throws java.security.NoSuchAlgorithmException
Throws:
java.security.NoSuchAlgorithmException

fromString

public static EncryptionAlgorithm fromString(java.lang.String name)
                                      throws java.security.NoSuchAlgorithmException
Deprecated. This method is deprecated because algorithm strings don't contain key length, which is necessary to distinguish between AES algorithms.

Throws:
java.security.NoSuchAlgorithmException

lookup

public static EncryptionAlgorithm lookup(java.lang.String algName,
                                         java.lang.String modeName,
                                         java.lang.String paddingName,
                                         int keyStrength)
                                  throws java.security.NoSuchAlgorithmException
Throws:
java.security.NoSuchAlgorithmException

getBlockSize

public int getBlockSize()
The blocksize of the algorithm in bytes. Stream algorithms (such as RC4) have a blocksize of 1.


isPadded

public boolean isPadded()
Deprecated. Call getPaddingType() instead.

Returns true if this algorithm performs padding.


getPaddingType

public EncryptionAlgorithm.Padding getPaddingType()
Returns the type of padding for this algorithm.


getIVLength

public int getIVLength()
Returns the number of bytes that this algorithm expects in its initialization vector.

Returns:
The size in bytes of the IV for this algorithm. A size of 0 means this algorithm does not take an IV.