Programmer Reference : Cryptography : Message Authentication Code (MAC)
Message Authentication Code (MAC)
Module Implementation: OpenSSLCryptoInterfaceMAC
This module implements message authentication code (MAC) algorithms such as HMAC and CMAC. In addition to data integrity, MAC also provides authentication.
Note: Internal classes are italicized and will only contain a short description.
See the class-side examples in the OpenSSLMessageAuthenticationCodeExamples class for additional usage detail.
MAC
OSSslMacCtx: Abstract MAC context class.
OSSslMac
Abstract superclass of concrete MAC algorithms.
Class methods: API
allMacNames
Answer a sorted listing of all supported mac names
Answers:
< SequenceableCollection>
 
allMacsCollect: aBlock
Answer a Collection that is created by iteratively
evaluating the one argument block, @aBlock using each element of
the receiver as an argument.
Fail if @aBlock is not a one-argument Block.
Arguments:
aBlock - <Block> 1-arg
Answers:
<SequenceableCollection>
 
allMacsDo: aBlock
Evaluate a one-arg block on all known macs.
Arguments:
aBlock - <Block> 1-arg block with mac <OSSslMac> as param
 
allMacsSelect: aBlock
Answer a SequenceableCollection that is created by iteratively evaluating
the one argument block, @aBlock using an element of receiver and
adding the element to the returned SequenceableCollection only if
aBlock evaluates to the Boolean true.
Fail if aBlock is not a one-argument Block.
Fail if the result of @aBlock is not a Boolean.
Arguments:
aBlock - <Block> 1-arg
Answers:
<SequenceableCollection>
 
Class methods: Creation
named: aMacName
Answer the <OSSslMac> associated with @aMacName.
This performs a fast lookup, and if that fails then it queries OpenSSL.
If OpenSSL is unable to locate it, it could be because the library was compiled
in such a way that it left it out.
Arguments:
aMacName - <String>
Answers:
<OSSslMac> - mac object
<OpenSSLError> - error object
 
Class methods: Factory
cmac
Answer a mac object configured for CMAC
 
hmac
Answer a mac object configured for HMAC
 
Instance methods: Accessing
longName
Answer the longName <String> of this mac
Answers:
<String> - longName
 
name
Answer the shortName <String> of this mac
Answers:
<String> - shortName
 
shortName
Answer the shortName <String> of this mac
Answers:
<String> - shortName
 
Instance methods: Equality
= anOSSslMac
Two MAC algorithms are considered equal if they are both OSSslMac objects
and they share the same context class
 
Instance methods: High-Level API - MAC
digest: aByteObject key: aKey using: anObject
Compute and Answer the message authentication code (MAC) <ByteArray> for
@aByteObject using the key @aKey and mac parameter @anObject.
For HMAC, the mac parameter is a digest <OSSslDigest>
For CMAC, the mac paramter is a cipher <OSSslCipher>
Arguments:
aByteObject - @see implementors of isOpenSSLByteObject for types
aKey - @see implementors of isOpenSSLByteObject for types
anObject - <Object>
Answers:
<ByteArray> computed keyed hash for message authentication
<OpenSSLError> error object
 
printableDigest: aByteObject key: aKey using: anObject
Compute and Answer the message authentication code (MAC) <String> in hex for
@aByteObject using the key @aKey and mac parameter @anObject.
For HMAC, the mac parameter is a digest <OSSslDigest>
For CMAC, the mac paramter is a cipher <OSSslCipher>
Arguments:
aByteObject - @see implementors of isOpenSSLByteObject for types
aKey - @see implementors of isOpenSSLByteObject for types
anObject - <Object>
Answers:
<String> computed keyed hash for message authentication in hex
<OpenSSLError> error object
 
HMAC
HMAC is a Message Authentication Code which is based on a hash function.
OSSslHmacCtx
Instance of this class are used to represent the calculation of an HMAC against a set of data.
Class methods: Creation
createNewFromDigest: anOSSslDigest key: aKey
Create a new HMAC_CTX instance and initialize it with the provided digest anOSSslDigest and key aKey
Arguments:
anOSSslDigest - <OSSslDigest>
aKey - @see implementors of isOpenSSLByteObject for types
Answers:
<OSSslHmacCtx> - new instance
<OpenSSLError compatible error> - error object
 
Instance methods: Accessing
digestSize
Answer the size of the digest.
Answers:
<Integer> - digest size
 
digestSize: anInteger
Set the internal state of the digest size.
Arguments:
anInteger - <Integer> long integer value
 
osDigest: anOSSslDigest key: aKey
Set the key and digest of this HMAC. This is required when using the Low-Level API because its not required to (re)pass in the key and digest on every call...therefore it must be known that they were set for safety.
Arguments:
anOSSslDigest - <OSSslDigest>
aKey - @see implementors of isOpenSSLByteObject for types
 
CMAC
CMAC is a Message Authentication Code which is based on a cipher.
OSSslCmacCtx
Instance of this class are used to represent the calculation of an HMAC against a set of data.
Class methods: Creation
createNewFromCipher: anOSSslCipher key: aKey
Create a new CMAC_CTX instance and initialize it with the provided digest @anOSSslCipher and key @aKey
Arguments:
anOSSslCipher - <OSSslCipher>
aKey - @see implementors of isOpenSSLByteObject for types
Answers:
<OSSslCmacCtx> - new instance
<OpenSSLError compatible error> - error object
 
Instance methods: Accessing
osCipher: anOSSslCipher key: aKey
Set the key and cipher of this CMAC.
Answers:
anOSSslCipher - <OSSslCipher>
aKey - @see implementors of isOpenSSLByteObject for types
 
osCipherCtx
Answer the cipher ctx that was created by the CMAC context.
We do not own this memory and do not need to track it, so create a static reference
Answers:
<OSSslCipherCtx>
Extensions
OSSslCipher
cmacDigest: aByteObject key: aKey
Compute and Answer the message authentication code (MAC) <ByteArray> for @aByteObject using the key @aKey and this cipher instance.
Arguments:
aByteObject - @see implementors of isOpenSSLByteObject for types
aKey - @see implementors of isOpenSSLByteObject for types
Answers:
<ByteArray> - computed message authentication code
 
cmacPrintableDigest: aByteObject key: aKey
Compute and Answer the message authentication code (MAC) <String> for aByteObject using the key aKey and this cipher instance.
Arguments:
aByteObject - a @see implementors of isOpenSSLByteObject for types
aKey - @see implementors of isOpenSSLByteObject for types
Answers:
<String> computed keyed hash for message authentication in hex
 
OSSslDigest
hmacDigest: aByteObject key: aKey
Compute and Answer the message authentication code (MAC) <ByteArray> for aByteObject using the key aKey and this message digest instance.
Arguments:
aByteObject - @see implementors of isOpenSSLByteObject for types
aKey - @see implementors of isOpenSSLByteObject for types
Answers:
<ByteArray> - computed message authentication code
 
hmacPrintableDigest: aByteObject key: aKey
Compute and Answer the message authentication code (MAC) <String> for aByteObject using the key aKey and this message digest instance.
Arguments:
aByteObject - @see implementors of isOpenSSLByteObject for types
aKey - @see implementors of isOpenSSLByteObject for types
Answers:
<String> computed keyed hash for message authentication in hex
 
Last modified date: 08/09/2017