@c =================================================================== @c
@c    serrano/prgm/project/bigloo/manuals/digest.texi                  @c
@c    ------------------------------------------------------------     @c
@c    Author      :  Manuel Serrano                                    @c
@c    Creation    :  Sat Dec 16 07:09:05 2006                          @c
@c    Last change :                                                    @c
@c    Copyright   :  2006 Manuel Serrano                               @c
@c    ------------------------------------------------------------     @c
@c    Digest                                                           @c
@c =================================================================== @c

@c ------------------------------------------------------------------- @c
@c    Digest                                                           @c
@c ------------------------------------------------------------------- @c
@node Digest, CRC, Date, Standard Library
@comment  node-name,  next,  previous,  up
@section Digest
@cindex Digest
@cindex base64
@cindex md5
@cindex sha1
@cindex sha256
@cindex sha512

@deffn {bigloo procedure} base64-encode string [padding 64]
@deffnx {bigloo procedure} base64-decode string [no-eof-padding]
@cindex base64
Encodes (respec. decodes) a string into a base64 representation.

When decoding, if the optional parameter @var{no-eof-padding} is
@code{#t}, the decoding success even if the input stream is not padded
with @code{=} characters.
@end deffn

@deffn {bigloo procedure} base64-encode-port input-port output-port [padding 64]
@deffnx {bigloo procedure} base64-decode-port input-port output-port [no-eof-padding]
@cindex base64
Encodes (respec. decodes) an input port into a base64 representation.

When decode succeeds, @var{base64-decode-port} returns @code{#t}, it
returns @code{#f} otherwise.

When decoding, if the optional parameter @var{no-eof-padding} is
@code{#t}, the decoding success even if the input stream is not padded
with @code{=} characters.
@end deffn

@deffn {bigloo procedure} pem-read-file file-name
@deffnx {bigloo procedure} pem-decode-port input-port output-port
Reads a PEM (Privacy Enhanced Mail) base64 encoded file.
@end deffn

@deffn {bigloo procedure} md5sum obj
@deffnx {bigloo procedure} md5sum-string string
@deffnx {bigloo procedure} md5sum-mmap mmap
@deffnx {bigloo procedure} md5sum-file string
@deffnx {bigloo procedure} md5sum-port input-port
Computes MD5 message digest.

The function @code{md5sum} dispatches over its argument and invokes the
ad-hoc function. That is, it invokes @code{md5sum-string} if its 
argument is a string, @code{md5sum-mmap} if it is a mmap, 
@code{md5sum-port} if its argument is an input port.
@end deffn

@deffn {bigloo procedure} hmac-md5sum-string key string
Computes the Hmac MD5 authentication:

@smalllisp
(hmac-md5sum-string (make-string 16 #a011) "Hi There") 
  @result{} "9294727a3638bb1c13f48ef8158bfc9d"
@end smalllisp
@end deffn

@deffn {bigloo procedure} cram-md5sum-string user key string
Challenge-Response Authentication Mechanism as specified in RFC 2195.

The function @code{cram-md5sum-string} assumes that data is base64 encoded.
The result is also base64 encoded.
@end deffn

@deffn {bigloo procedure} sha1sum obj
@deffnx {bigloo procedure} sha1sum-string string
@deffnx {bigloo procedure} sha1sum-mmap mmap
@deffnx {bigloo procedure} sha1sum-file string
@deffnx {bigloo procedure} sha1sum-port input-port
Computes SHA1 message digest.

The function @code{sha1sum} dispatches over its argument and invokes the
ad-hoc function. That is, it invokes @code{sha1sum-string} if its 
argument is a string, @code{sha1sum-mmap} if it is a mmap, 
@code{sha1sum-port} if its argument is an input port.
@end deffn

@deffn {bigloo procedure} hmac-sha1sum-string key string
Computes the Hmac SHA1 authentication:
@end deffn

@deffn {bigloo procedure} sha256sum obj
@deffnx {bigloo procedure} sha256sum-string string
@deffnx {bigloo procedure} sha256sum-mmap mmap
@deffnx {bigloo procedure} sha256sum-file string
@deffnx {bigloo procedure} sha256sum-port input-port
@deffnx {bigloo procedure} sha512sum obj
@deffnx {bigloo procedure} sha512sum-string string
@deffnx {bigloo procedure} sha512sum-mmap mmap
@deffnx {bigloo procedure} sha512sum-file string
@deffnx {bigloo procedure} sha512sum-port input-port
Computes SHA256 and SHA512 message digest.

The function @code{sha256sum} (respec. @code{sha512sum}) dispatches over
its argument and invokes the ad-hoc function. That is, it invokes
@code{sha256sum-string} if its argument is a string,
@code{sha256sum-mmap} if it is a mmap, @code{sha256sum-port} if its
argument is an input port.
@end deffn

@deffn {bigloo procedure} hmac-sha256sum-string key string
@deffnx {bigloo procedure} hmac-sha512sum-string key string
Computes the Hmac SHA256 and SHA512 authentication.
@end deffn


