emacs.d/clones/lisp/www.cliki.net/Ironclad.html

111 lines
8.1 KiB
HTML
Raw Normal View History

2022-10-07 15:47:14 +02:00
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>CLiki: Ironclad</title>
<link rel="alternate" type="application/atom+xml" title="ATOM feed of edits to current article"
href="https://www.cliki.net/site/feed/article.atom?title=Ironclad">
<link rel="stylesheet" href="static/css/style.css">
<link rel="stylesheet" href="static/css/colorize.css">
</head>
<body>
<span class="hidden">CLiki - Ironclad</span>
<div id="content"><div id="content-area"><div id="article-title">Ironclad</div><div id="article">Ironclad is a Common Lisp <a href="Cryptography.html" class="category">Cryptography</a> package; several block encryption algorithms and hash functions are included with the initial release. Its initial impetus was to unify several of the cryptographic packages for Common Lisp (such as the <a href="MD5.html" class="internal">MD5</a> and <a href="SHA1.html" class="internal">SHA1</a> implementations floating around), but it aims at providing a cryptographic toolkit similar in scope to something like OpenSSL or Crypto++.<p><ul>
<li>Supported ciphers: AES, DES, 3DES, <a href="Blowfish.html" class="internal">Blowfish</a>, Twofish, RC5, RC6, <a href="ARC4.html" class="internal">Arcfour</a> (RC4)
</li>
<li>Supported hash functions: MD4, MD5, SHA1, SHA256, Tiger, <a href="Adler32.html" class="internal">Adler32</a>, CRC32 (also supports tree hashes)
</li>
<li>
<a href="RFC.html" class="category">RFC</a> <a href="https://www.ietf.org/rfc/rfc2104.txt">2104</a> HMACs and <a href="RFC.html" class="category">RFC</a> <a href="https://www.ietf.org/rfc/rfc4493.txt">4493</a> CMACs
</li>
<li>Public key schemes: DSA signing and verification
</li>
<li>Key derivation functions: PBKDF1, PBKDF2 (<a href="RFC.html" class="category">RFC</a> <a href="https://www.ietf.org/rfc/rfc2898.txt">2898</a>)
</li>
</ul>
The Ironclad homepage and package documentation can be found at: <a href="https://github.com/sharplispers/ironclad">https://github.com/sharplispers/ironclad</a><p>(Originally located at <a href="http://method-combination.net/lisp/ironclad/">http://method-combination.net/lisp/ironclad/</a> and now maintained by <a href="sharplispers.html" class="category">sharplispers</a>.)<p>The SHA-1 and SHA-256 hash functions do not work under <a href="CLISP.html" class="internal">CLISP</a> versions earlier than 2.34. Please upgrade your <a href="CLISP.html" class="internal">CLISP</a> installation. (The failures are related to <a href="CLISP.html" class="internal">CLISP</a>'s handling of (LOOP ... FINALLY ...).)<p>Ironclad is distributed under a liberal <a href="X11.html" class="internal">X11</a>/MIT-like license.<p><h2><a href="Debian&#32;package.html" class="category">Debian package</a></h2><p>Ironclad has been <a href="https://packages.debian.org/sid/lisp/cl-ironclad">packaged for Debian</a>. You can just apt-get install it.<p><h2>Using Ironclad</h2><p><a href="http://web.archive.org/web/20200402044748/http://penzin.net/ironclad/">RSA With Ironclad—The Missing Manual</a> is an article about using the RSA functionality that is currently implemented in Ironclad.<p>Tell us how you are using Ironclad:<p><ul>
<li> To encrypt passwords for a web site, for that I created the following function:<p><pre class="item">(defun hash-password (password)
(ironclad:byte-array-to-hex-string
(ironclad:digest-sequence
:sha256
(ironclad:ascii-string-to-byte-array password))))</pre>
</li><p><li> Very simple example of encrypting and decrypting a message using the blowfish algorithm:<p><pre class="item">(push "/home/mcarter/ironclad_0.20.1/" asdf:*central-registry*) ; or something similar
(asdf:oos 'asdf:load-op 'ironclad)<p>(defun cipher-example (message password)
(let* ((iv (ironclad:ascii-string-to-byte-array password))
(cipher (ironclad:make-cipher :blowfish :mode :ecb :key iv)))
(setf message (ironclad:ascii-string-to-byte-array message))
(format t "original message as bytes:~A~%" message)
(ironclad:encrypt-in-place cipher message)
(format t "encrypted message as bytes:~A~%" message)
(ironclad:decrypt-in-place cipher message)
;; convert the message back to a string
(setf message (coerce message 'list))
(setf message (mapcar #'code-char message))
(setf message (coerce message 'string))
(format t "your original message was:*~A*~%" message)))<p>* (cipher-example "ironclad is a way of encrypting and decrypting messages" "my password")<p>original message as bytes:#(105 114 111 110 99 108 97 100 32 105 115 32 97 32
119 97 121 32 111 102 32 101 110 99 114 121 112
116 105 110 103 32 97 110 100 32 100 101 99 114
121 112 116 105 110 103 32 109 101 115 115 97 103
101 115)
encrypted message as bytes:#(206 106 66 158 68 233 4 198 157 196 72 39 13 110
140 102 0 27 7 177 80 46 144 203 187 69 89 95 208
51 206 149 172 158 127 210 90 210 19 240 224 252
137 13 19 206 188 20 101 115 115 97 103 101 115)
your original message was:*ironclad is a way of encrypting and decrypting messages*
NIL</pre><p></li>
<li> A more functional (hopefully simpler) example<p><pre class="item">(ql:quickload :ironclad)
(defun get-cipher (key)
(ironclad:make-cipher :blowfish
:mode :ecb
:key (ironclad:ascii-string-to-byte-array key)))<p>(defun encrypt (plaintext key)
(let ((cipher (get-cipher key))
(msg (ironclad:ascii-string-to-byte-array plaintext)))
(ironclad:encrypt-in-place cipher msg)
(ironclad:octets-to-integer msg)))<p>(defun decrypt (ciphertext-int key)
(let ((cipher (get-cipher key))
(msg (ironclad:integer-to-octets ciphertext-int)))
(ironclad:decrypt-in-place cipher msg)
(coerce (mapcar #'code-char (coerce msg 'list)) 'string)))<p>* (defvar test (encrypt "A simple test message" "pass"))
TEST<p>* test
369463901797626567104213850270827601164336028018533<p>* (decrypt test "pass")
"A simple test message"</pre>
</li>
</ul></div></div>
<div id="footer" class="buttonbar"><ul><li><a href="Ironclad.html">Current version</a></li>
<li><a href="https://www.cliki.net/site/history?article=Ironclad">History</a></li>
<li><a href="https://www.cliki.net/site/backlinks?article=Ironclad">Backlinks</a></li><li><a href="https://www.cliki.net/site/edit-article?title=Ironclad&amp;from-revision=3828043568">Edit</a></li><li><a href="https://www.cliki.net/site/edit-article?create=t">Create</a></li></ul></div>
</div>
<div id="header-buttons" class="buttonbar">
<ul>
<li><a href="https://www.cliki.net/">Home</a></li>
<li><a href="https://www.cliki.net/site/recent-changes">Recent Changes</a></li>
<li><a href="CLiki.html">About</a></li>
<li><a href="Text&#32;Formatting.html">Text Formatting</a></li>
<li><a href="https://www.cliki.net/site/tools">Tools</a></li>
</ul>
<div id="search">
<form action="https://www.cliki.net/site/search">
<label for="search_query" class="hidden">Search CLiki</label>
<input type="text" name="query" id="search_query" value="" />
<input type="submit" value="search" />
</form>
</div>
</div>
<div id="pageheader">
<div id="header">
<span id="logo">CLiki</span>
<span id="slogan">the common lisp wiki</span>
<div id="login"><form method="post" action="https://www.cliki.net/site/login">
<label for="login_name" class="hidden">Account name</label>
<input type="text" name="name" id="login_name" class="login_input" />
<label for= "login_password" class="hidden">Password</label>
<input type="password" name="password" id="login_password" class="login_input" />
<input type="submit" name="login" value="login" id="login_submit" /><br />
<div id="register"><a href="https://www.cliki.net/site/register">register</a></div>
<input type="submit" name="reset-pw" value="reset password" id="reset_pw" />
</form>
</div>
</div>
</div>
</body></html>