Note: This is taken from the Chicken Wiki, where a more recent version could be available.
crypt
Description
Bindings to cryptlib.
Author
Thomas Christian Chust
Requirements
None
Download
crypt.egg
Documentation
cryptlib is a high level cryptography library written by Peter Gutmann. You can find information and downloads for it at http://www.cs.auckland.ac.nz/~pgut001/cryptlib
At the time of writing of this code, the library is available under the same license conditions as this code.
The bindings in this package provide the same functionality as the functions documented in the original cryptlib documentation, with the following exceptions:
- All constants named CRYPT_xxx_yyy are named CRYPT-xxx-yyy in Scheme code
- All functions named cryptXxxYyy are named crypt-xxx-yyy in Scheme code
- None of the bindings returns an error code. Usually the return value is (void). In case of error, an exception of the composite kind (exn crypt) is signalled. It contains the parameters message (with a descriptive message of the error condition) and code (with the cryptlib error code)
- All crypt-create-xxx functions and other functions creating an object like crypt-import-cert take no output parameter for the created object but rather return the new object.
- All functions expecting a buffer of data and a size as input arguments (like crypt-set-attribute-string) can take a string or byte-vector as a single input argument in that place or any object and a size as two input arguments.
- crypt-pop-data, which expects a buffer and a maximum size as an output argument can take either a string or a byte-vector as a single output argument in that place or a maximum size as a single argument in that place or a maximum size and any object. They return the list (buffer bytes-read) where buffer (if it was not given) is a freshly allocated string of maximum size bytes.
A list of all functions behaving slightly differently from the cryptlib documentation follows, sorted alphabetically:
- crypt-async-query returns #t if an asynchronous operation is running, #f otherwise
- crypt-ca-cert-management gets one parameter less than the normal cryptlib function call, but an additional optional parameter indicates whether the first argument of the cryptlib call should be used (and the retrieved value returned) or not.
- crypt-ca-get-item returns the result retrieved in the second parameter to the cryptlib call
- crypt-check-signature-ex returns the result retrieved in the last parameter to the cryptlib call if its optional argument is true
- crypt-create-cert returns the result retrieved in the first parameter to the cryptlib call
- crypt-create-context returns the result retrieved in the first parameter to the cryptlib call
- crypt-create-envelope returns the result retrieved in the first parameter to the cryptlib call
- crypt-create-session returns the result retrieved in the first parameter to the cryptlib call
- crypt-create-signature returns the result retrieved in the first two parameters to the cryptlib call as a string
- crypt-create-signature-ex returns the result retrieved in the first parameter to the cryptlib call as a string
- crypt-device-create-context returns the result retrieved in the second parameter to the cryptlib call
- crypt-device-open returns the result retrieved in the first parameter to the cryptlib call
- crypt-device-query-capability returns the following values
- name of the algorithm
- block size
- minimum key size
- standard key size
- maximum key size
- crypt-export-cert returns the result retrieved in the first two parameters to the cryptlib call as a string
- crypt-export-key returns the result retrieved in the first two parameters to the cryptlib call as a string
- crypt-export-key-ex returns the result retrieved in the first two parameters to the cryptlib call as a string
- crypt-get-attribute returns the result retrieved in the last parameter to the cryptlib call
- crypt-get-attribute-string returns the result retrieved in the last two parameters to the cryptlib call as a string
- crypt-get-cert-extension returns the data retrieved in the last two parameters to the cryptlib call as a string and the critical flag as a boolean
- crypt-get-private-key returns the data retrieved in the 3rd parameter to the cryptlib call
- crypt-get-publib-key returns the data retrieved in the second parameter to the cryptlib call
- crypt-import-cert returns the data retrieved in the last parameter to the cryptlib call. Also note that the parameters have been reordered (user is the first now) to let the length parameter be optional
- crypt-keyset-open returns the data retrieved in the first parameter to the cryptlib call.
- crypt-pop-data returns the buffer and the number of bytes read into it. also note that the sequence (and number) of parameters is different from the original cryptlib version
- crypt-push-data returns the number of bytes copied from the buffer
- crypt-query-capability returns the following values
- name of the algorithm
- block size
- minimum key size
- standard key size
- maximum key size
- crypt-query-object returns the following values
- the object type
- the encryption algorithm
- the encryption mode
- the hash algorithm
- the salt for derived keys
- the size of the salt
In addition two wrappers for crypt-pop-data and crypt-push-data are provided:
- crypt-input-port is given a cryplib session or envelope object and returns an input port which wraps calls to crypt-pop-data. closing the port does NOT destroy the underlying cryptlib object.
- crypt-output-port is given a cryptlib session or envelope object and returns an output port which wraps calls to crypt-push-data. closing the port does NOT destroy the underlying cryptlib object.
Changelog
- 1.1 Replaced use of (end-of-file) with #!eof
- 1.0 Initial release
License
Copyright (c) 2004 by Thomas Christian Chust <chust@web.de>.
All rights reserved.
Redistribution and use in source and binary forms, with or
without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided
with the distribution.
* Neither the name of the author nor the names of its
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.