Message Digests
Module Implementation: OpenSSLCryptoInterfaceMD
This module implements message digests, sometimes called hashes, to provide data-integrity to data.
Note: Internal classes are italicized and will only contain a short description.
See the class-side examples in the OpenSSLMessageDigestExamples class for additional usage detail.
Digests
OSSslDigest
This object wraps a specific message digest algorithm. It contains an API for one-shot digests.
Class methods: API
allDigestsCollect: aBlock
Answer a Collection that is created by iteratively evaluating the one argument block, aBlock using each element of the receiver as an argument.
Arguments:
aBlock - <Block> 1-arg
Answers:
< SequenceableCollection>
 
allDigestsDo: aBlock
Evaluate a one-arg block on all supported digests. The external library may only support a subset based on how it was compiled, so a check is performed to see if it is included in the list.
Arguments:
<Block> 1-arg block with digest <OSSslDigest> as param
 
allDigestsNames
Answer a sorted listing of all supported digest names. This will take the external library into account since what digests are available depend on compiler flags used.
Answers:
<SequenceableCollection> digest names
 
allDigestsSelect: 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 eturned <SequenceableCollection> only if aBlock evaluates to the Boolean true.
Arguments:
aBlock - <Block> 1-arg
Answers:
< SequenceableCollection>
 
Class methods: Creation
named: aDigestName
Answer the <OSSslDigest> associated with aDigestName. 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:
aDigestName- <String>
Answers:
<OSSslDigest> - digest object
<OpenSSLError> - error object
 
Class methods: Factory
The methods in this category all have the same name as the Digest algorithm and answer an OSSslDigest instance.
Note: OpenSSL may have been compiled without support for some of the factory algorithms, in this case error objects will be answered.
Example:
sha_256
Answer the Digest Object for the SHA_256 algorithm.
Answers:
<OSSslDigest>
 
Instance methods: Accessing
blockSize
Answer the block size of the message digest
Answers:
<Integer>
 
longName
Answer the longName <String> of this message digest
Answers:
<String> - long name
 
name
Answer the shortName <String> of this message digest
Answers:
<String> - short name
 
shortName
Answer the shortName <String> of this message digest
Answers:
<String> - short name
 
size
Answer the size of the message digest (i.e. size of hash).
Answers:
<Integer> - size
 
type
Answers the type of the passed message digest or context.
Answers:
<Integer> - type
 
Instance methods: API - Digest
digest: aByteObject
Compute and Answer the digest value <ByteArray> for aByteObject.
Arguments:
aByteObject - a collection of bytes THAT MUST KNOW ITS SIZE (i.e. String | ByteArray | OSStringZ)
Answers:
<ByteArray> - computed message digest
 
printableDigest: aByteObject
Compute and Answer the hex-formatted digest value <String> for aByteObject.
Arguments:
aByteObject - a collection of bytes THAT MUST KNOW ITS SIZE (i.e. String | ByteArray | OSStringZ)
Answers:
<String> computed message hex digest
 
Instance methods: Testing
isCtx
Test if this is a context object
Answers:
<Boolean> - false
 
OSSslDigestCtx
This is the context object that represents a particular session of a message digest computation. It contains an API for one-shot and streaming message digesting.
Class methods: Creation
createNew
Create a new EVP_MD_CTX instance and initialize it.
Answers:
< OSSslDigestCtx> - new instance
<OpenSSLError compatible error> - error object
 
createNewFromDigest: aDigest
Create a new EVP_MD_CTX instance
Arguments:
aDigest - < OSSslDigest > message digest algorithm object
Answers:
< OSSslDigestCtx > - new instance
<OpenSSLError compatible error> - error object
 
Instance methods: Duplication
duplicate
Answers a managed duplicate of this Digest Context.
Answers:
< OSSslDigestCtx> - new duplicate instance
 
Instance methods: High-Level API - Digest
digest: aByteObject
Compute and Answer the digest value <ByteArray> for aByteObject.
Arguments:
aByteObject - a collection of bytes THAT MUST KNOW ITS SIZE (i.e. String | ByteArray | OSStringZ)
Answers:
<ByteArray> - computed message digest
 
digest: aByteObject length: length
Compute and Answer the digest value <ByteArray> for length bytes from the data aByteObject.
Arguments:
aByteObject - byte object (i.e. ByteArray | EsString | OSObject)
length - length of the byte object
Answers:
<ByteArray> - computed message digest
 
printableDigest: aByteObject
Compute and Answer the hex-formatted digest value <String> for aByteObject.
Arguments:
aByteObject - a collection of bytes THAT MUST KNOW ITS SIZE (i.e. String | ByteArray | OSStringZ)
Answers:
<String> computed message hex digest
 
printableDigest: aByteObject length: length
Compute and Answer the printable digest value <String> for length bytes from the data aByteObject.
Arguments:
aByteObject - byte object (i.e. ByteArray | EsString | OSObject)
length - length of the byte object
Answers:
<String> printable digest in hex
 
Instance methods: Low-Level API - Digests
finish
Answers the digest value from the context After calling this...no more update: operations are allowed. You must call reset to reinit the state.
Answers:
<ByteArray> - computed digest
 
finishInto: aByteObject
Retrieves the digest value from the context and places it in aByteObject. Answers the number of data bytes actually written (length of the digest) This will be EVP_MAX_MD_SIZE at most.
aByteObject is allowed to be an OSObject, but be careful when using these. It is expected that aByteObject has AT LEAST the length of the digest as it's allocated size. To be safe, always allocate EVP_MAX_MD_SIZE worth of bytes. After calling this...no more update: operations are allowed. You must call reset reinit the state.
Arguments:
aByteObject - byte object (i.e. ByteArray | EsString | OSObject)
Answers:
<Integer> - number of bytes written
 
reset
Resets the Digest context to it's default state with the associated digest.
Answers:
< OSSslDigestsCtx> self
 
update: aByteObject
Update the digest from aByteObject.
Arguments:
aByteObject - a collection of bytes THAT MUST KNOW ITS SIZE (i.e. String | ByteArray | OSStringZ)
Answers:
<Integer> - 1 for success
 
update: aByteObject length: length
Update the digest from length number of bytes from aByteObject.
Arguments:
aByteObject - byte object (i.e. ByteArray | EsString | OSObject)
length - <Integer> length of aByteObject
Answers:
<Integer> - 1 for success
 
Instance methods: Testing
isCtx
Test if this is a context object
Answers:
<Boolean> - true
BIO
OSSslDigestBIO
OpenSSL BIO object that updates an internal hash value as data is read or written from it. Data that passes through it is unaltered. It can be chained together with other BIOs to create a high-performance crypto pipeline.
Class methods: Creation
createNewFromContext: anOSSslMessageDigestCtx
Create a new instance of the cipher BIO from the digest context.
Arguments:
anOSSslMessageDigestCtx - <OSSslDigestCtx>
Answers:
< OSSslDigestBIO> new instance
<OpenSSLError compatible error> - error object
 
createNewFromDigest: anOSSslMessageDigest
Create a new instance of the cipher BIO from the digest.
Arguments:
anOSSslMessageDigest - <OSSslDigest>
Answers:
< OSSslDigestBIO> new instance
<OpenSSLError compatible error> - error object
 
Instance methods: API
osDigestCtx
Answer the message digest context object associated with this BIO.
Answers:
< OSSslDigestCtx>
 
Instance methods: Conversion
asString
Answer the complete data within this bio as an ASCII String
which represents the printable HEX of the digest
Answers:
<String>
Extensions
ByteArray
asOpenSSLHexString
Answer the contents of aByteArray as an ASCII String which represents the printable HEX value.
Answers:
<String>
 
OSSslBIO
newDigestBIO: aMessageDigestOrCtx
Convenience Method for creating message digest BIOs
Answers:
< OSSslDigestBIO>
OSSslBIOMethod
messageDigest
Answer the Message Digest BIO-Method.
Answers:
< OSSslBIOMethod> digest bio method
 
 
Last modified date: 12/02/2016