[ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
15.1.1 String to Key
The following string->key algorithms take a password string and transform it to a key string of a given length. In all the functions the len is expressed in bytes.
- Bigloo Cryptography procedure: string->key-zero str len
If the length of the input string str is greater or equal to len bytes then the first str characters are returned. Otherwise str is suffixed with ’0’ (
#a000
) characters.
- Bigloo Cryptography procedure: string->key-hash str len hash-fun
The input string str is run through the given hash function hash-fun. The result is then concatenated multiple times (with itself) until a string of the len bytes is obtained.
In the following example we encrypt some-message using a password
"my password"
. The password will be transformed to 256 bits (32 bytes) using thestring->key256
function.(define (string->key256 password) (string->key-hash password 32 (lambda (str) (string-hex-intern (sha1sum str))))) (encrypt 'aes some-message "my password" :string->key string->key256)
Note that the following example yields an identical result:
(define (string->key256 password) (string->key-hash password 32 (lambda (str) (string-hex-intern (sha1sum str))))) (encrypt 'aes some-message (string->key256 "my password") :string->key (lambda (x) x))
- Bigloo Cryptography procedure: string->key-simple str len hash-fun
-
This function implements the simple s2k algorithm of OpenPGP (RFC 2440). Basically str is run through the hash-fun several times until the concatenation of the results is long enough. At each iteration the string is prefixed with count ’0’-bytes (where count is the iteration counter).
- Bigloo Cryptography procedure: string->key-salted str len hash-fun salt
This function implements the salted s2k algorithm of OpenPGP (RFC 2440). Similar to
string->key-simple
but the input string is first prefixed with salt.
- Bigloo Cryptography procedure: string->key-iterated-salted str len hash-fun salt count
This function implements the iterated salted s2k algorithm of OpenPGP (RFC 2440). The variable count must be a long. This algorithm is an extension of
string->key-salted
where the hash function is applied repeatedly.This function has changed with release 3.4b. Earlier versions could be incompatible with RFC 2440.
[ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
This document was generated on March 31, 2014 using texi2html 5.0.