Description
Message digests.
Canonicalization needs these: RDFC-1.0 names SHA-256 as its default and SHA-384 as the one alternative, and the canonical blank node identifiers a conforming processor produces depend on which was used, so this is a specification requirement rather than a utility that happens to live here.
The implementation is GNAT's, which couples this crate to the GNAT runtime. That is a deliberate and recorded choice: every compiler this ecosystem targets is GNAT, and carrying our own SHA would mean maintaining cryptographic code to avoid a dependency the crate already has in every other respect.
Digest
function Digest
(Value : String; Algorithm : Hash_Algorithm) return String
Digest with whichever algorithm was asked for. Canonicalization compares digests as strings and never assumes a length, so the two are interchangeable here.
Parameters
- Value
Bytes to digest
- Algorithm
Which digest to use
Return value
The digest as lowercase hexadecimal
Hash_Algorithm
type Hash_Algorithm is (SHA_256, SHA_384);
The digests RDFC-1.0 admits.
Enumeration literals
- SHA_256
The default
- SHA_384
The alternative a manifest may ask for
Hex_Digest
subtype Hex_Digest is String (1 .. 64);
A SHA-256 digest rendered as lowercase hexadecimal, which is the form RDFC-1.0 hashes and compares.
Hex_Digest_384
subtype Hex_Digest_384 is String (1 .. 96);
The same for SHA-384.
SHA_256
function SHA_256 (Value : String) return Hex_Digest
Digest a byte string with SHA-256.
Parameters
- Value
Bytes to digest
Return value
The digest as 64 lowercase hexadecimal characters
SHA_384
function SHA_384 (Value : String) return Hex_Digest_384
Digest a byte string with SHA-384.
Parameters
- Value
Bytes to digest
Return value
The digest as 96 lowercase hexadecimal characters