Package org.mozilla.jss.pkcs12
Class MacData
java.lang.Object
org.mozilla.jss.pkcs12.MacData
- All Implemented Interfaces:
ASN1Value
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
A Template for decoding a MacData from its BER encoding. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final int
private DigestInfo
private INTEGER
private OCTET_STRING
private static final int
private static final Tag
private static final MacData.Template
-
Constructor Summary
ConstructorsConstructorDescriptionMacData()
MacData
(DigestInfo mac, OCTET_STRING macSalt, INTEGER macIterationCount) Creates a MacData from the given parameters.Creates a MacData by computing a HMAC on the given bytes.MacData
(Password password, byte[] macSalt, int iterations, byte[] toBeMACed, AlgorithmIdentifier algID) Creates a MacData by computing a HMAC on the given bytes. -
Method Summary
Modifier and TypeMethodDescriptionvoid
encode
(OutputStream ostream) Write this value's DER encoding to an output stream using its own base tag.void
encode
(Tag implicitTag, OutputStream ostream) Write this value's DER encoding to an output stream using an implicit tag.getMac()
getTag()
Returns the base tag for this type, not counting any tags that may be imposed on it by its context.static final MacData.Template
-
Field Details
-
mac
-
macSalt
-
macIterationCount
-
DEFAULT_ITERATIONS
private static final int DEFAULT_ITERATIONS- See Also:
-
SALT_LENGTH
private static final int SALT_LENGTH- See Also:
-
TAG
-
templateInstance
-
-
Constructor Details
-
MacData
public MacData() -
MacData
Creates a MacData from the given parameters.- Parameters:
macIterationCount
- 1 is the default and should be used for maximum compatibility. null can also be used, in which case the macIterationCount will be omitted from the structure (and the default value of 1 will be implied).
-
MacData
public MacData(Password password, byte[] macSalt, int iterations, byte[] toBeMACed) throws NotInitializedException, DigestException, TokenException, CharConversionException Creates a MacData by computing a HMAC on the given bytes. An HMAC is a message authentication code, which is a keyed digest. It proves not only that data has not been tampered with, but also that the entity that created the HMAC possessed the symmetric key.- Parameters:
password
- The password used to generate a key using a PBE mechanism.macSalt
- The salt used as input to the PBE key generation mechanism. If null is passed in, new random salt will be created.iterations
- The iteration count for creating the PBE key.toBeMACed
- The data on which the HMAC will be computed.- Throws:
NotInitializedException
- If the crypto subsystem has not been initialized yet.TokenException
- If an error occurs on a crypto token.DigestException
CharConversionException
-
MacData
public MacData(Password password, byte[] macSalt, int iterations, byte[] toBeMACed, AlgorithmIdentifier algID) throws NotInitializedException, DigestException, TokenException, CharConversionException Creates a MacData by computing a HMAC on the given bytes. An HMAC is a message authentication code, which is a keyed digest. It proves not only that data has not been tampered with, but also that the entity that created the HMAC possessed the symmetric key.- Parameters:
password
- The password used to generate a key using a PBE mechanism.macSalt
- The salt used as input to the PBE key generation mechanism. If null is passed in, new random salt will be created.iterations
- The iteration count for creating the PBE key.toBeMACed
- The data on which the HMAC will be computed.algID
- The algorithm used to compute the HMAC, If null the SHA1 will be used.- Throws:
NotInitializedException
- If the crypto subsystem has not been initialized yet.TokenException
- If an error occurs on a crypto token.DigestException
CharConversionException
-
-
Method Details
-
getMac
-
getMacSalt
-
getMacIterationCount
-
getTag
Description copied from interface:ASN1Value
Returns the base tag for this type, not counting any tags that may be imposed on it by its context. -
encode
Description copied from interface:ASN1Value
Write this value's DER encoding to an output stream using its own base tag.- Specified by:
encode
in interfaceASN1Value
- Parameters:
ostream
- Output stream.- Throws:
IOException
- If an error occurred.
-
encode
Description copied from interface:ASN1Value
Write this value's DER encoding to an output stream using an implicit tag.- Specified by:
encode
in interfaceASN1Value
- Parameters:
implicitTag
- Implicit tag.ostream
- Output stream.- Throws:
IOException
- If an error occurred.
-
getTemplate
-