diff --git a/NEWS b/NEWS index 0f9fe9f..d1e57ab 100644 --- a/NEWS +++ b/NEWS @@ -1,11 +1,15 @@ -*- mode: outline -*- -* Changes since version 0.59 +* Version 0.60, released 2024-02-29 ** new features Added crc32c digest. +** bug fixes + +Fixed some undefined behavior for ECL with some compilers. + * Version 0.59, released 2023-07-24 ** new features diff --git a/README.org b/README.org index aa8d8fa..df0f2c3 100644 --- a/README.org +++ b/README.org @@ -80,8 +80,8 @@ thread. There is an example showing how it can be done in the section about :CUSTOM_ID: installation :END: -The current version of Ironclad is 0.59. It can be downloaded -at [[https://github.com/sharplispers/ironclad/archive/v0.59.tar.gz]]. +The current version of Ironclad is 0.60. It can be downloaded +at [[https://github.com/sharplispers/ironclad/archive/v0.60.tar.gz]]. If you are feeling adventurous, you can download a bleeding-edge version at [[https://github.com/sharplispers/ironclad]]. diff --git a/doc/ironclad.html b/doc/ironclad.html index 55f01f3..39cad20 100644 --- a/doc/ironclad.html +++ b/doc/ironclad.html @@ -1,7 +1,7 @@
- +-The current version of Ironclad is 0.59. It can be downloaded -at https://github.com/sharplispers/ironclad/archive/v0.59.tar.gz. +The current version of Ironclad is 0.60. It can be downloaded +at https://github.com/sharplispers/ironclad/archive/v0.60.tar.gz. If you are feeling adventurous, you can download a bleeding-edge version at https://github.com/sharplispers/ironclad.
@@ -197,7 +197,7 @@(make-cipher name &key key mode initialization-vector padding tweak) => cipher
+(make-cipher name &key key mode initialization-vector padding tweak) => cipher
-name denotes the encryption algorithm to use. list-all-ciphers will tell you +name denotes the encryption algorithm to use. list-all-ciphers will tell you the names of all supported ciphers. They are:
initialization-vector (IV) should be supplied only if mode requires one.
initialization-vector should be a (simple-array (unsigned-byte 8) (*))
.
-The supplied IV should be the same length as the block-length of name.
+The supplied IV should be the same length as the block-length of name.
The Chacha and Salsa20 stream ciphers also use an initialization
vector (nonce). It should be 8 or 12 bytes long for Chacha, 8 bytes long
for Salsa20, and 24 bytes long for XChacha and XSalsa20.
@@ -293,8 +293,8 @@
-If padding is supplied, the specified padding method will be used by encrypt
-and decrypt to handle short blocks when the :handle-final-block
argument is
+If padding is supplied, the specified padding method will be used by encrypt
+and decrypt to handle short blocks when the :handle-final-block
argument is
supplied. padding will only be used if the mode is ECB or CBC. The possible
values for padding are :pkcs7
, :ansi-x923
and :iso-7816-4
.
(encrypt cipher plaintext ciphertext &key plaintext-start plaintext-end ciphertext-start handle-final-block) => n-bytes-consumed, n-bytes-produced
+(encrypt cipher plaintext ciphertext &key plaintext-start plaintext-end ciphertext-start handle-final-block) => n-bytes-consumed, n-bytes-produced
(decrypt cipher ciphertext plaintext &key ciphertext-start ciphertext-end plaintext-start handle-final-block) => n-bytes-consumed, n-bytes-produced
+(decrypt cipher ciphertext plaintext &key ciphertext-start ciphertext-end plaintext-start handle-final-block) => n-bytes-consumed, n-bytes-produced
(encrypt-in-place cipher text &key start end) => n-bytes-consumed, n-bytes-produced
+(encrypt-in-place cipher text &key start end) => n-bytes-consumed, n-bytes-produced
(decrypt-in-place cipher text &key start end) => n-bytes-consumed, n-bytes-produced
+(decrypt-in-place cipher text &key start end) => n-bytes-consumed, n-bytes-produced
+(encrypt cipher text text :plaintext-start start :plaintext-end end :ciphertext-start start) (decrypt cipher text text :ciphertext-start start :ciphertext-end end :plaintext-start start)-Note: encrypt-in-place and decrypt-in-place do not support -a handle-final-block parameter as encrypt and decrypt do. If you +Note: encrypt-in-place and decrypt-in-place do not support +a handle-final-block parameter as encrypt and decrypt do. If you need the functionality that handle-final-block provides, then you -need to use encrypt and decrypt. +need to use encrypt and decrypt.
Note: n-bytes-consumed and n-bytes-produced may not always be equal to the length of the data specified in the call to -encrypt-in-place or decrypt-in-place. This subtlely is also present in -encrypt or decrypt. +encrypt-in-place or decrypt-in-place. This subtlely is also present in +encrypt or decrypt.
@@ -384,32 +384,32 @@Ciphers
(list-all-ciphers) => list +(list-all-ciphers) => list
-Returns a list of cipher-names that may be validly passed to make-cipher. +Returns a list of cipher-names that may be validly passed to make-cipher.
(cipher-supported-p name) => boolean +(cipher-supported-p name) => boolean
-Returns t
if name would be in the list returned by list-all-ciphers,
+Returns t
if name would be in the list returned by list-all-ciphers,
nil
otherwise.
(key-lengths cipher) => list +(key-lengths cipher) => list
(block-length cipher) => number +(block-length cipher) => number
Block ciphers in CTR mode and some stream ciphers have the ability to change the current position within the key stream in constant time instead of having to @@ -440,21 +440,21 @@
(keystream-position cipher &optional position) => number or boolean
+(keystream-position cipher &optional position) => number or boolean
Return or change the current position within the key stream of a cipher. -When position is not supplied, keystream-position returns the current position +When position is not supplied, keystream-position returns the current position in the key stream, or nil if it can't be determined. When position is supplied, the key stream position of the cipher is set to that position if -possible. keystream-position returns t if the repositioning is performed +possible. keystream-position returns t if the repositioning is performed successfully, or nil otherwise.
-keystream-position can be used with the following ciphers: +keystream-position can be used with the following ciphers:
(make-digest digest-name &rest keys &key &allow-other-keys) => digester +(make-digest digest-name &rest keys &key &allow-other-keys) => digester
Returns a digest object. digest-name is a keyword naming the algorithm you wish digester to use. The supported digest names can be found -by calling list-all-digests. They are: +by calling list-all-digests. They are:
-Like for make-cipher, digest-name should be a symbol in the
+Like for make-cipher, digest-name should be a symbol in the
keyword
or ironclad
packages.
+(make-digest :shake256 :output-length 123)-@@ -613,7 +614,7 @@(update-digest digester thing &key &allow-other-keys) => (values) +(update-digest digester thing &key &allow-other-keys) => (values)Digests
suffice. -+(let ((digester (ironclad:make-digest :sha1)) (array (make-array 16 :element-type '(unsigned-byte 8) :initial-element 0))) ;; Update with 16 zeroes. @@ -633,14 +634,14 @@Digests
Update the internal state of digester with the contents of stream, which must respond toread-byte
orread-sequence
with a(simple-array (unsigned-byte 8) (*))
and return digester. It -differs from digest-stream, below, in that you may need to digest data +differs from digest-stream, below, in that you may need to digest data before or after the contents of stream (this happens, for instance, when signing the contents of some file).-@@ -651,24 +652,24 @@(produce-digest digester &key digest digest-start) => digest +(produce-digest digester &key digest digest-start) => digest
Digests
If digest is provided, the computed digest will be placed into digest starting at digest-start. digest must be a -
(simple-array (unsigned-byte 8) (*))
. An insufficient-buffer-space +(simple-array (unsigned-byte 8) (*))
. An insufficient-buffer-space error will be signaled if there is insufficient space in digest.
Several high-level convenience functions that encapsulate common -sequences of make-digest, update-digest and produce-digest are +sequences of make-digest, update-digest and produce-digest are provided by Ironclad as well. They come in two flavors: the first -takes a digest name as would be provided to make-digest. The second +takes a digest name as would be provided to make-digest. The second way to call these functions is to provide an actual digest object as the first argument. So one can say:
-+(ironclad:digest-sequence :md5 *buffer*)@@ -676,18 +677,18 @@High-level convenience functions
or, equivalently: -+(let ((digester (ironclad:make-digest :md5))) (ironclad:digest-sequence digester *buffer*))-The second form comes in handy if you plan on reusing the digest object. +The second form comes in handy if you plan on reusing the digest object.
-@@ -695,12 +696,12 @@(digest-sequence digest-spec sequence &rest args &key start end digest digest-start) => digest +(digest-sequence digest-spec sequence &rest args &key start end digest digest-start) => digestHigh-level convenience functions
Returns the digest of the subsequence of sequence bounded by start and end, according to digest-name. sequence must be a(vector (unsigned-byte 8))
. digest and digest-start -are as in produce-digest. +are as in produce-digest.-@@ -709,7 +710,7 @@(digest-stream digest-spec stream &rest args &key buffer start end digest digest-start) => digest +(digest-stream digest-spec stream &rest args &key buffer start end digest digest-start) => digestHigh-level convenience functions
stream.read-byte
must be a legal operation on stream and return an(unsigned-byte 8)
. In a similar fashion,read-sequence
on stream must support reading into a(simple-array (unsigned-byte 8) (*))
. -digest and digest-start are as in produce-digest. +digest and digest-start are as in produce-digest.@@ -720,13 +721,13 @@
High-level convenience functions
-(digest-file digest-spec pathname &rest args &key buffer start end digest digest-start) => digest +(digest-file digest-spec pathname &rest args &key buffer start end digest digest-start) => digestReturns the digest of the contents of the file named by pathname. -digest and digest-start are as in produce-digest. +digest and digest-start are as in produce-digest.
@@ -737,32 +738,32 @@
High-level convenience functions
(list-all-digests) => list +(list-all-digests) => list
-Returns a list whose elements may be validly passed to make-digest. +Returns a list whose elements may be validly passed to make-digest.
(digest-supported-p name) => boolean +(digest-supported-p name) => boolean
-Returns t
if name would be in the list returned by list-all-digests,
+Returns t
if name would be in the list returned by list-all-digests,
nil
otherwise.
(digest-length digest) => number +(digest-length digest) => number
Ironclad digests are CLOS objects; the interesting thing about this
for most purposes is that functions like reinitialize-instance
are
@@ -783,7 +784,7 @@
md5sum
program like so:
-+(defun digest-sum-files (digest-name &rest files) (unless files (error "no files given to digest")) @@ -800,15 +801,15 @@Miscellaneous
Ironclad supports tree hashes, as described in Tree Hash EXchange format. You create tree hashes as if you were creating a digest:
-+(ironclad:make-digest :tree-hash)@@ -819,7 +820,7 @@Tree hashes
intent obvious has also been provided: -+(ironclad:make-tiger-tree-hash)@@ -828,7 +829,7 @@Tree hashes
Tiger: -+(ironclad:make-digest '(:treehash :digest :sha256))@@ -836,7 +837,7 @@Tree hashes
Or you might wish to use a different segment size: -+(ironclad:make-digest '(:tree-hash :block-length 16384))@@ -873,14 +874,14 @@Message authentication codes
-(make-mac mac-name key &rest args) => mac +(make-mac mac-name key &rest args) => mac
Return a MAC object initialized with a secret key. mac-name is a keyword naming the algorithm you wish mac to use. The supported -MACs can be found by calling list-all-macs. They are: +MACs can be found by calling list-all-macs. They are:
-Like for make-digest, mac-name should be a symbol in the keyword
+Like for make-digest, mac-name should be a symbol in the keyword
or ironclad
packages.
+(make-mac :blake2-mac key &key digest-length) (make-mac :blake2s-mac key &key digest-length) (make-mac :cmac key cipher-name) @@ -914,34 +915,34 @@Message authentication codes
-When making a Blake2 MAC, the length of the key passed to make-mac +When making a Blake2 MAC, the length of the key passed to make-mac must be 64 bytes.
-When making a Blake2s MAC, the length of the key passed to make-mac +When making a Blake2s MAC, the length of the key passed to make-mac must be 32 bytes.
-When making a CMAC, cipher-name must have a block-length of either 8, 16, 32, +When making a CMAC, cipher-name must have a block-length of either 8, 16, 32, 64 or 128; this restriction is satisfied by many ciphers in Ironclad with the notable exception of stream ciphers. key must be an acceptable key for cipher-name.
-When making a GMAC, cipher-name must have a block-length of 16. key must be +When making a GMAC, cipher-name must have a block-length of 16. key must be an acceptable key for cipher-name.
-When making a Poly1305 MAC, the length of the key passed to make-mac must be +When making a Poly1305 MAC, the length of the key passed to make-mac must be 32 bytes.
-When making a SipHash MAC, the length of the key passed to make-mac must be 16 +When making a SipHash MAC, the length of the key passed to make-mac must be 16 bytes. digest-length is 8 by default, but it can also be set to 16. By default, compression-rounds is 2 and finalization-rounds is 4.
@@ -965,12 +966,12 @@Message authentication codes
-The :key argument is the secret key, as provided to make-mac. +The :key argument is the secret key, as provided to make-mac.
(update-mac mac thing &key &allow-other-keys) => (values) +(update-mac mac thing &key &allow-other-keys) => (values)
+(let* ((key (random-data 32)) (mac (ironclad:make-mac :hmac key :sha256)) (array (make-array 16 :element-type '(unsigned-byte 8) :initial-element 0))) @@ -1003,7 +1004,7 @@Message authentication codes
-@@ -1016,46 +1017,46 @@(produce-mac mac &key digest digest-start) => digest +(produce-mac mac &key digest digest-start) => digest
Message authentication codes
If digest is provided, the computed digest will be placed into digest starting at digest-start. digest must be a -
(simple-array (unsigned-byte 8) (*))
. An insufficient-buffer-space +(simple-array (unsigned-byte 8) (*))
. An insufficient-buffer-space error will be signaled if there is insufficient space in digest.-The length of the digest returned by produce-mac is determined by the -kind of MAC and the extra arguments passed to make-mac: +The length of the digest returned by produce-mac is determined by the +kind of MAC and the extra arguments passed to make-mac:
(list-all-macs) => list +(list-all-macs) => list
-Returns a list whose elements may be validly passed to make-mac. +Returns a list whose elements may be validly passed to make-mac.
(mac-supported-p name) => boolean +(mac-supported-p name) => boolean
-Returns t
if name would be in the list returned by list-all-macs,
+Returns t
if name would be in the list returned by list-all-macs,
nil
otherwise.
(make-authenticated-encryption-mode name &rest args) => mode
+(make-authenticated-encryption-mode name &rest args) => mode
-name denotes the mode to use. list-all-authenticated-encryption-modes will +name denotes the mode to use. list-all-authenticated-encryption-modes will tell you the names of all the supported modes. They are:
+(make-authenticated-encryption-mode :eax &key tag cipher-name key initialization-vector) (make-authenticated-encryption-mode :etm &key tag cipher mac) (make-authenticated-encryption-mode :gcm &key tag cipher-name key initialization-vector) @@ -1103,8 +1104,8 @@Authenticated encryption
If tag is specified, it will be used at the end of decryption (when the handle-final-block flag ist
) to check the authenticity of the data. Abad-authentication-tag
error will be signaled if the data is not authentic. -If you don't specify it, you will have to call produce-tag after decryption and -check that the tags match (e.g. using constant-time-equal). +If you don't specify it, you will have to call produce-tag after decryption and +check that the tags match (e.g. using constant-time-equal).@@ -1112,18 +1113,18 @@
Authenticated encryption
-When using ETM, cipher must be a cipher object created by make-cipher. -mac must be a mac object created by make-mac. +When using ETM, cipher must be a cipher object created by make-cipher. +mac must be a mac object created by make-mac.
-When using GCM, cipher-name must have a block-length of 16 bytes. key must be a suitable key +When using GCM, cipher-name must have a block-length of 16 bytes. key must be a suitable key for the chosen cipher.
-@@ -1134,11 +1135,11 @@(process-associated-data mode data &key start end) => (values) +(process-associated-data mode data &key start end) => (values)
Authenticated encryption
-An authenticated encryption object can be used with the encrypt, decrypt, -encrypt-message and decrypt-message functions. +An authenticated encryption object can be used with the encrypt, decrypt, +encrypt-message and decrypt-message functions.
-+(encrypt mode plaintext ciphertext &key plaintext-start plaintext-end ciphertext-start handle-final-block) (decrypt mode ciphertext plaintext &key ciphertext-start ciphertext-end plaintext-start handle-final-block) (encrypt-message mode message &key start end associated-data associated-data-start associated-data-end) @@ -1147,7 +1148,7 @@Authenticated encryption
-@@ -1155,33 +1156,33 @@(produce-tag mode &key tag tag-start) => tag +(produce-tag mode &key tag tag-start) => tag
Authenticated encryption
Return the authentication tag of the data processed by mode so far. If tag is provided, the computed tag will be placed into tag starting at tag-start. tag must be a(simple-array (unsigned-byte 8) (*))
. An -insufficient-buffer-space error will be signaled if there is insufficient space +insufficient-buffer-space error will be signaled if there is insufficient space in tag.
(list-all-authenticated-encryption-modes) => list +(list-all-authenticated-encryption-modes) => list
Returns a list whose elements may be validly passed to -make-authenticated-encryption-mode. +make-authenticated-encryption-mode.
(authenticated-encryption-mode-supported-p name) => boolean +(authenticated-encryption-mode-supported-p name) => boolean
Returns t
if name would be in the list returned by
-list-all-authenticated-encryption-modes nil
otherwise.
+list-all-authenticated-encryption-modes nil
otherwise.
(derive-key kdf passphrase salt iteration-count key-length) => digest +(derive-key kdf passphrase salt iteration-count key-length) => digest
-Given a key derivation function object (produced by make-kdf),
+Given a key derivation function object (produced by make-kdf),
a password and salt (both must be of type
(simple-array (unsigned-byte 8) (*))
), and number of iterations,
returns the password digest as a byte array of length key-length.
@@ -1228,7 +1229,7 @@
(make-kdf kind &key digest n r p block-count additional-key additional-data) => kdf
+(make-kdf kind &key digest n r p block-count additional-key additional-data) => kdf
The default Scrypt parameters are N = 4096, r = 8, and p = 2. Please note that depending on the values of N and r, -derive-key may not be able to allocate sufficient space for its +derive-key may not be able to allocate sufficient space for its temporary arrays.
@@ -1281,18 +1282,18 @@(list-all-kdfs) => list +(list-all-kdfs) => list
-Returns a list of KDF kinds that may be validly passed to make-kdf. +Returns a list of KDF kinds that may be validly passed to make-kdf.
Ironclad comes with convenience functions for using PBKDF1 and PBKDF2 to store passwords. @@ -1300,7 +1301,7 @@
(pbkdf2-hash-password password &key salt digest iterations) => password
+(pbkdf2-hash-password password &key salt digest iterations) => password
(pbkdf2-hash-password-to-combined-string password &key salt digest iterations) => password
+(pbkdf2-hash-password-to-combined-string password &key salt digest iterations) => password
(pbkdf2-check-password password combined-salt-and-digest) => boolean +(pbkdf2-check-password password combined-salt-and-digest) => boolean
Given a password byte vector and a combined salt and digest string -produced by pbkdf2-hash-password-to-combined-string, checks whether +produced by pbkdf2-hash-password-to-combined-string, checks whether the password is valid.
(generate-key-pair kind &key num-bits &allow-other-keys) => private-key, public-key +(generate-key-pair kind &key num-bits &allow-other-keys) => private-key, public-key
+(generate-key-pair :elgamal :compatible-with-key bob-public-key)-(list-all-key-pair-kinds) => list +(list-all-key-pair-kinds) => listReturns a list of key pair kinds that may be validly passed to -generate-key-pair. +generate-key-pair.
(make-public-key kind &key &allow-other-keys) => public-key +(make-public-key kind &key &allow-other-keys) => public-key
+(make-public-key :curve25519 &key y) => public-key (make-public-key :curve448 &key y) => public-key (make-public-key :dsa &key p q g y) => public-key @@ -1449,7 +1450,7 @@Key construction
-@@ -1459,7 +1460,7 @@(make-private-key kind &key &allow-other-keys) => private-key +(make-private-key kind &key &allow-other-keys) => private-keyKey construction
specialize on kind, below. -+(make-private-key :curve25519 &key x y) => private-key (make-private-key :curve448 &key x y) => private-key (make-private-key :dsa &key p q g y x) => private-key @@ -1508,43 +1509,43 @@Key construction
-The destructure-public-key and destructure-private-key functions can +The destructure-public-key and destructure-private-key functions can be useful if you need to store keys somewhere for future use.
(destructure-public-key public-key) => plist +(destructure-public-key public-key) => plist
Return the elements of a public key in a plist. The indicators of the -plist match the &key arguments of the make-public-key method. +plist match the &key arguments of the make-public-key method.
(destructure-private-key private-key) => plist +(destructure-private-key private-key) => plist
Return the elements of a private key in a plist. The indicators of the -plist match the &key arguments of the make-private-key method. +plist match the &key arguments of the make-private-key method.
(sign-message key message &key start end &allow-other-keys) => signature +(sign-message key message &key start end &allow-other-keys) => signature
-Note: The sign-message does not perform the hashing of the data. You +Note: The sign-message does not perform the hashing of the data. You should hash your data using your favorite hash function, and then use -this hash as the message passed to sign-message. +this hash as the message passed to sign-message.
(verify-signature key message signature &key start end &allow-other-keys) => boolean +(verify-signature key message signature &key start end &allow-other-keys) => boolean
To be secure, RSA signature requires the message to be padded. The pss key parameter is provided to pad (or unpad) the message @@ -1584,7 +1585,7 @@
t
(which will use the sha1 digest).
-+(sign-message rsa-private-key message :pss t) => signature (verify-signature rsa-public-key message signature :pss t) => boolean@@ -1596,19 +1597,19 @@Padding
DSA, Elgamal and ECDSA (Secp256k1, Secp256r1, Secp384r1 and Secp521r1) signatures require the generation of a nonce. You must never sign two different messages with the same key and the same nonce, or anyone having these two signatures will be able compute your private key. Ironclad uses the -generate-signature-nonce method which by default generates random nonces. +generate-signature-nonce method which by default generates random nonces.
(generate-signature-nonce (key message &optional parameters)) => nonce
+(generate-signature-nonce (key message &optional parameters)) => nonce
If instead of random nonces, you want to have deterministic nonces (e.g. like -in RFC 6979), you will have to redefine generate-signature-nonce. For example, +in RFC 6979), you will have to redefine generate-signature-nonce. For example, to have deterministic nonces for Secp256k1 ECDSA signatures, you could do something like:
-+(defmethod generate-signature-nonce ((key secp256k1-private-key) message &optional parameters) (declare (ignore parameters)) (compute-deterministic-nonce key message)) @@ -1633,22 +1634,22 @@Signature nonce
-sign-message returns signatures as octet vectors. When the signature +sign-message returns signatures as octet vectors. When the signature contains several values (e.g. the R and S values of DSA signatures), the octet vector is the concatenation of these values (e.g. the first half of the vector is the R value, the second half is the S value). -You can use the make-signature and destructure-signature functions if +You can use the make-signature and destructure-signature functions if you need access to the elements of a signature (e.g. to use a different kind of serialization).
(make-signature kind &key &allow-other-keys) => signature +(make-signature kind &key &allow-other-keys) => signature
+(make-signature :dsa &key r s n-bits) => signature (make-signature :ed25519 &key r s) => signature (make-signature :ed448 &key r s) => signature @@ -1688,23 +1689,23 @@Format of signatures
-(destructure-signature kind signature) => plist +(destructure-signature kind signature) => plistReturn the elements of a signature in a plist. The indicators of the -plist match the &key arguments of the make-signature method. +plist match the &key arguments of the make-signature method.
(encrypt-message key message &key start end &allow-other-keys) => encrypted-message +(encrypt-message key message &key start end &allow-other-keys) => encrypted-message
(decrypt-message key message &key start end n-bits &allow-other-keys) => decrypted-message +(decrypt-message key message &key start end n-bits &allow-other-keys) => decrypted-message
To be secure, RSA encryption requires the message to be padded. The oaep key parameter is provided to pad (or unpad) the message during @@ -1739,7 +1740,7 @@
t
(which will use the sha1 digest).
-+(encrypt-message rsa-public-key message :oaep t) => encrypted-message (decrypt-message rsa-private-key message :oaep t) => decrypted-message@@ -1751,23 +1752,23 @@Padding
-encrypt-message returns encrypted messages as octet vectors. When the +encrypt-message returns encrypted messages as octet vectors. When the message contains several values (e.g. the C1 and C2 values of Elgamal messages), the octet vector is the concatenation of these values (e.g. the first half of the vector is the big-endian representation of the C1 value, the second half is the C2 value). You can use the -make-message and destructure-message functions if you need access to +make-message and destructure-message functions if you need access to the elements of a message (e.g. to use a different kind of serialization).
(make-message kind &key &allow-other-keys) => message +(make-message kind &key &allow-other-keys) => message
+(make-message :elgamal &key c1 c2 n-bits) => message (make-message :rsa &key m n-bits) => message@@ -1794,23 +1795,23 @@Format of messages
-(destructure-message kind message) => plist +(destructure-message kind message) => plistReturn the elements of a message in a plist. The indicators of the -plist match the &key arguments of the make-message method. +plist match the &key arguments of the make-message method.
(diffie-hellman private-key public-key) => bytes +(diffie-hellman private-key public-key) => bytes
(ec-make-point kind &key &allow-other-keys) => point +(ec-make-point kind &key &allow-other-keys) => point
+(ec-make-point :curve25519 &key x) (ec-make-point :curve448 &key x) (ec-make-point :ed25519 &key x y) @@ -1852,18 +1853,18 @@Elliptic curve operations
-(ec-destructure-point p) => plist +(ec-destructure-point p) => plistReturn a plist containing the coordinates of the point P. The indicators of -the plist match the &key arguments of the ec-make-point method. +the plist match the &key arguments of the ec-make-point method.
-@@ -1873,7 +1874,7 @@(ec-point-on-curve p) => boolean +(ec-point-on-curve p) => booleanElliptic curve operations
-@@ -1883,7 +1884,7 @@(ec-point-equal p q) => boolean +(ec-point-equal p q) => booleanElliptic curve operations
-@@ -1893,7 +1894,7 @@(ec-double p) => point +(ec-double p) => pointElliptic curve operations
-@@ -1903,7 +1904,7 @@(ec-add p q) => point +(ec-add p q) => pointElliptic curve operations
-@@ -1913,7 +1914,7 @@(ec-scalar-mult p e) => point +(ec-scalar-mult p e) => pointElliptic curve operations
-@@ -1923,7 +1924,7 @@(ec-scalar-inv kind n) => integer +(ec-scalar-inv kind n) => integerElliptic curve operations
-@@ -1933,7 +1934,7 @@(ec-encode-scalar kind n) => vector +(ec-encode-scalar kind n) => vectorElliptic curve operations
-@@ -1943,7 +1944,7 @@(ec-decode-scalar kind octets) => integer +(ec-decode-scalar kind octets) => integerElliptic curve operations
-@@ -1953,7 +1954,7 @@(ec-encode-point p) => vector +(ec-encode-point p) => vectorElliptic curve operations
-@@ -1986,7 +1987,7 @@(ec-decode-point kind octets) => point +(ec-decode-point kind octets) => pointPseudo-random number generation
-@@ -1995,7 +1996,7 @@(make-prng name &key seed) => prng +(make-prng name &key seed) => prng
Pseudo-random number generation
-name denotes the style of PRNG to use. list-all-prngs will tell you +name denotes the style of PRNG to use. list-all-prngs will tell you the names of all supported PRNGs. Currently supported PRNGs are:
-In single-threaded applications, you should very rarely need to call make-prng; +In single-threaded applications, you should very rarely need to call make-prng; the default OS-provided PRNG should be appropriate in nearly all cases.
@@ -2037,7 +2038,7 @@+(make-thread (lambda () (let ((crypto:*prng* (crypto:make-prng :os))) (forms-for-thread-1)))) @@ -2049,7 +2050,7 @@Pseudo-random number generation
-@@ -2059,7 +2060,7 @@(list-all-prngs) => list +(list-all-prngs) => listPseudo-random number generation
-@@ -2070,7 +2071,7 @@(random-data num-bytes &optional prng) => bytes +(random-data num-bytes &optional prng) => bytes
Pseudo-random number generation
-@@ -2080,19 +2081,19 @@(random-bits num-bits &optional prng) => integer +(random-bits num-bits &optional prng) => integer
Pseudo-random number generation
-(strong-random limit &optional prng) => number +(strong-random limit &optional prng) => number
-A drop-in replacement for
common-lisp:random
, strong-random +A drop-in replacement forcommon-lisp:random
, strong-random generates a number (an integer if limit is an integer and a float if it is a float) between 0 and limit - 1 in an unbiased fashion.-@@ -2109,14 +2110,14 @@(read-os-random-seed source &optional prng) => reseed-count +(read-os-random-seed source &optional prng) => reseed-count
Pseudo-random number generation
-(read-seed path &optional prng) => t +(read-seed path &optional prng) => t
Read enough bytes from path to reseed prng, then generate a pseudo-random seed and write it back to path. If path doesn't -exist, calls read-os-random-seed to get a truly random seed from the +exist, calls read-os-random-seed to get a truly random seed from the OS. Note that reseeding does not reset the generator's state to the seed value; rather, it combines the generator's state with the seed to form a new state. @@ -2124,7 +2125,7 @@
Pseudo-random number generation
-@@ -2133,10 +2134,10 @@(write-seed path &optional prng) => t +(write-seed path &optional prng) => t
Pseudo-random number generation
++-Example
++(crypto:random-data 16) => #(61 145 133 130 220 200 90 86 0 101 62 169 0 40 101 78) @@ -2149,9 +2150,9 @@Example
-Fortuna
-++Fortuna
+-You should only use the Fortuna PRNG if your OS does not provided a sufficiently-good PRNG. If you use a Unix or Unix-like OS (e.g. @@ -2180,7 +2181,7 @@
Fortuna
Fortuna automatically feeds entropy from the pools back into its -random state when random-data is called, using a method designed to +random state when random-data is called, using a method designed to make it resistant to various avenues of attack; even in case of generator compromise it will return to a safe state within a bounded time. @@ -2200,7 +2201,7 @@
Fortuna
-@@ -2236,9 +2237,9 @@(add-random-event source pool-id event &optional prng) => pool-length +(add-random-event source pool-id event &optional prng) => pool-length
Gray streams
-Octet streams
-++-Octet streams
+Octet streams are very similar to Common Lisp's
string-stream
except they deal in octets instead of characters. @@ -2246,7 +2247,7 @@Octet streams
-@@ -2256,7 +2257,7 @@(make-octet-input-stream buffer &optional start end) => octet-input-stream +(make-octet-input-stream buffer &optional start end) => octet-input-stream
Octet streams
-@@ -2266,7 +2267,7 @@(make-octet-output-stream) => octet-output-stream +(make-octet-output-stream) => octet-output-streamOctet streams
-@@ -2277,7 +2278,7 @@(get-output-stream-octets stream) => octet-vector +(get-output-stream-octets stream) => octet-vectorOctet streams
-@@ -2289,7 +2290,7 @@(with-octet-input-stream ((var buffer &optional (start 0) end) &body body)) +(with-octet-input-stream ((var buffer &optional (start 0) end) &body body))Octet streams
-@@ -2297,14 +2298,14 @@(with-octet-output-stream ((var) &body body)) => bytes +(with-octet-output-stream ((var) &body body)) => bytesOctet streams
Within body, var is bound to an octet output stream. After all the forms in body have been executed, the data that has been written to var (and that hasn't been consumed by a call to -get-output-stream-octets within body) is returned. +get-output-stream-octets within body) is returned.-Digest streams
-++-Digest streams
+Digest streams compute a digest of the data written to them according to a specific digest algorithm. @@ -2313,7 +2314,7 @@
Digest streams
Example:
-+(defun frobbing-function (stream) ;; We want to compute a digest of the data being written to STREAM ;; without involving our callees in the process. @@ -2328,7 +2329,7 @@Digest streams
-@@ -2336,18 +2337,18 @@(make-digesting-stream digest &rest args) => stream +(make-digesting-stream digest &rest args) => stream
Digest streams
Make a stream that computes a digest of the data written to it according to the algorithm digest. The parameters that can be used by some algorithms can be specified as args. -produce-digest may be used to obtain a digest of all the data written +produce-digest may be used to obtain a digest of all the data written to the stream.-Note: Calling produce-digest on a digest stream does not alter +Note: Calling produce-digest on a digest stream does not alter the internal state of the digest.
-@@ -2360,9 +2361,9 @@(with-digesting-stream (var digest-name &rest args) &body body) => digest +(with-digesting-stream (var digest-name &rest args) &body body) => digestDigest streams
-Cipher streams
-++-Cipher streams
+Cipher streams encrypt or decrypt the data written to or read from them according to a specific cipher algorithm. @@ -2370,7 +2371,7 @@
Cipher streams
-@@ -2386,7 +2387,7 @@(make-encrypting-stream stream cipher mode key &key initialization-vector direction) => stream +(make-encrypting-stream stream cipher mode key &key initialization-vector direction) => stream
Cipher streams
-@@ -2403,12 +2404,12 @@(make-decrypting-stream stream cipher mode key &key initialization-vector direction) => stream +(make-decrypting-stream stream cipher mode key &key initialization-vector direction) => stream
Cipher streams
Note: Only stream ciphers and block ciphers in CTR, CFB, CFB8 or OFB mode are -supported by make-encrypting-stream and make-decrypting-stream. +supported by make-encrypting-stream and make-decrypting-stream.
-@@ -2419,7 +2420,7 @@(with-encrypting-stream ((var stream cipher mode key &key initialization-vector direction) &body body)) +(with-encrypting-stream ((var stream cipher mode key &key initialization-vector direction) &body body))Cipher streams
-@@ -2430,16 +2431,16 @@(with-decrypting-stream ((var stream cipher mode key &key initialization-vector direction) &body body)) +(with-decrypting-stream ((var stream cipher mode key &key initialization-vector direction) &body body))Cipher streams
-MAC streams
-++MAC streams
+MAC streams compute a message authentication code of the data written to them according to a specific MAC algorithm.
-@@ -2447,12 +2448,12 @@(make-authenticating-stream mac key &rest args) => stream +(make-authenticating-stream mac key &rest args) => stream
MAC streams
Make a stream that computes a MAC of the data written to it according to the algorithm mac initialized with a key. The parameters used to create the MAC can be specified as args. -produce-mac may be used to obtain a MAC of all the data written to the +produce-mac may be used to obtain a MAC of all the data written to the stream.-Note: Calling produce-mac on a MAC stream does not alter the +Note: Calling produce-mac on a MAC stream does not alter the internal state of the MAC.
@@ -2460,7 +2461,7 @@MAC streams
Example: encrypt some data and compute a MAC of the ciphertext
-+(let* ((data ...) (output-stream ...) (encryption-key ...) @@ -2483,7 +2484,7 @@MAC streams
-@@ -2501,7 +2502,7 @@(with-authenticating-stream (var mac-name key &rest args) &body body) => mac +(with-authenticating-stream (var mac-name key &rest args) &body body) => macMAC streams
Utility functions
-(ub16ref/le vector index) => value +(ub16ref/le vector index) => value (ub32ref/le vector index) => value (ub64ref/le vector index) => value@@ -2516,7 +2517,7 @@Utility functions
-(ub16ref/be vector index) => value +(ub16ref/be vector index) => value (ub32ref/be vector index) => value (ub64ref/be vector index) => value@@ -2528,41 +2529,41 @@Utility functions
-(byte-array-to-hex-string vector &key start end element-type) => string +(byte-array-to-hex-string vector &key start end element-type) => string (hex-string-to-byte-array string &key start end) => string (ascii-string-to-byte-array string &key start end) => vector-byte-array-to-hex-string converts the bytes of vector between +byte-array-to-hex-string converts the bytes of vector between start and end into a hexadecimal string. It is useful for converting digests to a more readable form. element-type indicates the element-type of the returned string.
-hex-string-to-byte-array parses a substring of string delimited +hex-string-to-byte-array parses a substring of string delimited start and end of hexadecimal digits into a byte array.
-ascii-string-to-byte-array is provided as a quick and dirty way to -convert a string to a byte array suitable for feeding to update-digest -or encrypt. Care should be taken to ensure that the provided string is +ascii-string-to-byte-array is provided as a quick and dirty way to +convert a string to a byte array suitable for feeding to update-digest +or encrypt. Care should be taken to ensure that the provided string is actually an ASCII string. start and end have their usual interpretations.
-(octets-to-integer octet-vec &key start end big-endian n-bits) => number +(octets-to-integer octet-vec &key start end big-endian n-bits) => number (integer-to-octets bignum &key n-bits big-endian) => vector-octets-to-integer converts the bytes of octet-vec between start +octets-to-integer converts the bytes of octet-vec between start and end to an integer as though the bytes denoted a number in base 256. big-endian is a boolean indicating whether the bytes are to be read in big-endian or little-endian order. n-bits specifies @@ -2571,12 +2572,12 @@
Utility functions
-integer-to-octets is the reverse operation. +integer-to-octets is the reverse operation.
-@@ -2584,20 +2585,20 @@(expt-mod n exponent modulus) => number +(expt-mod n exponent modulus) => number (expt-mod/unsafe n exponent modulus) => numberUtility functions
Raises n to the exponent power modulo modulus in a more efficient fashion than
(mod (expt n exponent) modulus)
. -expt-mod is using the Montgomery ladder algorithm to be more robust +expt-mod is using the Montgomery ladder algorithm to be more robust against timing attacks. -expt-mod/unsafe runs faster than expt-mod but is not safe against +expt-mod/unsafe runs faster than expt-mod but is not safe against timing attacks; don't use it on secret data.-(prime-p n &optional prng) => boolean +(prime-p n &optional prng) => boolean
-prime-p returns
t
if n has a high probability of being a prime number, and +prime-p returnst
if n has a high probability of being a prime number, andnil
if it is a composite number. The probable primality is determined by first doing trial divisions with small primes, then running several Miller-Rabin tests with random bases, and finally doing a Lucas test. The @@ -2608,7 +2609,7 @@Utility functions
-@@ -2619,7 +2620,7 @@make-random-salt &optional size => bytes +make-random-salt &optional size => bytes
Utility functions
-@@ -2636,7 +2637,7 @@constant-time-equal data1 data2 => boolean +constant-time-equal data1 data2 => booleanUtility functions
Conditions
--@@ -2647,152 +2648,152 @@ironclad-error +ironclad-errorConditions
-initialization-vector-not-supplied +initialization-vector-not-supplied-This error is signaled by make-cipher when an initialization vector is +This error is signaled by make-cipher when an initialization vector is not provided and the requested mode requires an initialization vector.
-invalid-initialization-vector +invalid-initialization-vectorThis error is signaled when an invalid initialization vector is -supplied to make-cipher (e.g. when the length of the initialization +supplied to make-cipher (e.g. when the length of the initialization vector does not match the block length of the cipher).
-invalid-key-length +invalid-key-length-This error is signaled when the key provided to make-cipher is not of +This error is signaled when the key provided to make-cipher is not of an acceptable length for the requested cipher.
-unsupported-cipher +unsupported-cipher-This error is signaled when the cipher-name provided to make-cipher -is not cipher-supported-p. +This error is signaled when the cipher-name provided to make-cipher +is not cipher-supported-p.
-unsupported-mode +unsupported-modeThis error is signaled when the mode provided to -make-cipher is not mode-supported-p. +make-cipher is not mode-supported-p.
-unsupported-padding +unsupported-padding-This error is signaled when the padding provided to make-cipher is not +This error is signaled when the padding provided to make-cipher is not supported.
-unsupported-digest +unsupported-digestThis error is signaled when the digest-name provided to -make-digest is not digest-supported-p. +make-digest is not digest-supported-p.
-unsupported-mac +unsupported-macThis error is signaled when the mac-name provided to -make-mac is not mac-supported-p. +make-mac is not mac-supported-p.
-insufficient-buffer-space +insufficient-buffer-spaceThis error is signaled when Ironclad needs to stuff some data into -a buffer (e.g. when the user provides digest to produce-digest and +a buffer (e.g. when the user provides digest to produce-digest and there is insufficient space).
-key-not-supplied +key-not-suppliedThis error is signaled when a :key argument is not provided -to make-cipher. +to make-cipher.
-unsupported-kdf +unsupported-kdfThis error is signaled when an invalid KDF name is provided -to make-kdf. +to make-kdf.
-unsupported-scrypt-cost-factors +unsupported-scrypt-cost-factorsThis error is signaled when invalid Scrypt cost factors are provided -to make-kdf. +to make-kdf.
-unsupported-argon2-cost-factors +unsupported-argon2-cost-factorsThis error is signaled when invalid Argon2 parameters are provided -to make-kdf. +to make-kdf.
-@@ -2803,84 +2804,84 @@invalid-padding +invalid-paddingConditions
-invalid-mac-parameter +invalid-mac-parameterThis error is signaled when an invalid parameter is provided -to make-mac. +to make-mac.
-invalid-signature-length +invalid-signature-lengthThis error is signaled when a signature with an invalid length is provided -to verify-signature or destructure-signature. +to verify-signature or destructure-signature.
-invalid-message-length +invalid-message-lengthThis error is signaled when a message with an invalid length is provided -to encrypt-message, decrypt-message or destructure-message. +to encrypt-message, decrypt-message or destructure-message.
-missing-key-parameter +missing-key-parameterThis error is signaled when it is determined that a parameter is -missing in a call to make-public-key or make-private-key. +missing in a call to make-public-key or make-private-key.
-missing-message-parameter +missing-message-parameterThis error is signaled when it is determined that a parameter is -missing in a call to make-message. +missing in a call to make-message.
-missing-signature-parameter +missing-signature-parameterThis error is signaled when it is determined that a parameter is -missing in a call to make-signature. +missing in a call to make-signature.
-incompatible-keys +incompatible-keysThis error is signaled when incompatible keys are provided to -diffie-hellman. +diffie-hellman.
-@@ -2890,18 +2891,18 @@invalid-curve-point +invalid-curve-pointConditions
-invalid-public-key-length +invalid-public-key-lengthThis error is signaled when a public key with an invalid length is -provided to verify-signature. +provided to verify-signature.
-@@ -2911,18 +2912,18 @@oaep-decoding-error +oaep-decoding-errorConditions
-unsupported-authenticated-encryption-mode +unsupported-authenticated-encryption-modeThis error is signaled when an invalid mode name is provided to -make-authenticated-encryption-mode. +make-authenticated-encryption-mode.
-@@ -2943,15 +2944,15 @@bad-authentication-tag +bad-authentication-tagSubsystems (experimental)
For example if you need only AES and SHA256:
-+(asdf:load-system "ironclad/cipher/aes") (asdf:load-system "ironclad/digest/sha256")-Available subsystems
-++- \ No newline at end of file +Available subsystems
+
- ironclad
@@ -3065,4 +3066,4 @@
Available subsystems