The cl-sha1 Reference Manual

Next: , Previous: , Up: (dir)   [Contents][Index]

The cl-sha1 Reference Manual

This is the cl-sha1 Reference Manual, version 1.0, generated automatically by Declt version 4.0 beta 2 "William Riker" on Wed Jun 15 04:02:32 2022 GMT+0.

Table of Contents


1 Introduction

SHA1 Digest and HMAC for Common Lisp

A very simple implementation of SHA1 and HMAC-SHA1 for Common Lisp. The code is intended to be easy to follow and is therefore a little slower than it could be.

Quickstart

There are 6 functions exposed in the sha1 package:

(sha1-digest message)            ;=> digest
(sha1-hex message)               ;=> string
(sha1-base64 message)            ;=> string

(hmac-sha1-digest key message)   ;=> digest
(hmac-sha1-hex key message)      ;=> string
(hmac-sha1-base64 key message)   ;=> string

A digest is a list of 20 bytes. The -hex functions will return a hexadecimal string that is equal to the digest. The -base64 functions will return a base64-encoded string of the digest.

They key and message arguments can either be a sequence of bytes or a string (ASCII or UTF-8).

Some examples (from the Wikipedia pages):

CL-USER > (sha1-digest "")
(218 57 163 238 94 107 75 13 50 85 191 239 149 96 24 144 175 216 7 9)

CL-USER > (sha1-hex "The quick brown fox jumps over the lazy dog")
"2FD4E1C67A2D28FCED849EE1BB76E7391B93EB12"

CL-USER > (sha1-base64 "The quick brown fox jumps over the lazy dog")
"L9ThxnotKPzthJ7hu3bnORuT6xI="

CL-USER > (hmac-sha1-hex "key" "The quick brown fox jumps over the lazy dog")
"DE7C9B85B8B78AA6BC8A7A36F70A90701C9DB4D9"

That's it!


2 Systems

The main system appears first, followed by any subsystem dependency.


Previous: , Up: Systems   [Contents][Index]

2.1 cl-sha1

SHA1 Digest and HMAC for LispWorks.

Author

Jeffrey Massung

License

Apache 2.0

Version

1.0

Dependency

cl-base64 (system).

Source

cl-sha1.asd.

Child Component

sha1.lisp (file).


3 Files

Files are sorted by type and then listed depth-first from the systems components trees.


Previous: , Up: Files   [Contents][Index]

3.1 Lisp


Next: , Previous: , Up: Lisp   [Contents][Index]

3.1.1 cl-sha1/cl-sha1.asd

Source

cl-sha1.asd.

Parent Component

cl-sha1 (system).

ASDF Systems

cl-sha1.

Packages

sha1-asd.


Previous: , Up: Lisp   [Contents][Index]

3.1.2 cl-sha1/sha1.lisp

Source

cl-sha1.asd.

Parent Component

cl-sha1 (system).

Packages

sha1.

Public Interface
Internals

4 Packages

Packages are listed by definition order.


Next: , Previous: , Up: Packages   [Contents][Index]

4.1 sha1-asd

Source

cl-sha1.asd.

Use List
  • asdf/interface.
  • common-lisp.

Previous: , Up: Packages   [Contents][Index]

4.2 sha1

Source

sha1.lisp.

Use List

common-lisp.

Public Interface
Internals

5 Definitions

Definitions are sorted by export status, category, package, and then by lexicographic order.


Next: , Previous: , Up: Definitions   [Contents][Index]

5.1 Public Interface


5.1.1 Ordinary functions

Function: hmac-sha1-base64 (key message)

Return the HMAC-SHA1 base64-encoded digest for a byte sequence.

Package

sha1.

Source

sha1.lisp.

Function: hmac-sha1-digest (key message)

Return the HMAC-SHA1 digest for a byte sequence.

Package

sha1.

Source

sha1.lisp.

Function: hmac-sha1-hex (key message)

Return the HMAC-SHA1 hex digest for a byte sequence.

Package

sha1.

Source

sha1.lisp.

Function: sha1-base64 (message)

Return the SHA1 base64-encoded digest for a byte sequence.

Package

sha1.

Source

sha1.lisp.

Function: sha1-digest (message)

Return the SHA1 digest for a byte sequence.

Package

sha1.

Source

sha1.lisp.

Function: sha1-hex (message)

Return the SHA1 hex digest for a byte sequence.

Package

sha1.

Source

sha1.lisp.


5.2 Internals


Previous: , Up: Internals   [Contents][Index]

5.2.1 Ordinary functions

Function: digest (seq)

Create a SHA-1 digest from an adjustable vector containing the message.

Package

sha1.

Source

sha1.lisp.

Function: hash-digest (hh)

Convert a 160-bit hash to a 20-byte digest list.

Package

sha1.

Source

sha1.lisp.

Function: hash-vector (seq)

Convert x to an unsigned-byte vector.

Package

sha1.

Source

sha1.lisp.

Function: rotate-word (w &optional bits)

Rotate a 32-bit word left by bits.

Package

sha1.

Source

sha1.lisp.

Function: word (v chunk byte)

Read a 32-bit, big-endian word from a message chunk.

Package

sha1.

Source

sha1.lisp.


Appendix A Indexes


Next: , Previous: , Up: Indexes   [Contents][Index]

A.1 Concepts


Next: , Previous: , Up: Indexes   [Contents][Index]

A.3 Variables