ALX 2016-08-19 17:05:00:
See https://fossil.sowaswie.de/nacl/timeline (fossil repository) or http://sourceforge.net/projects/tclsnippets/files/nacl/ for precompiled binaries, source, ...
The package has TEA Tcl Extension Architecture and has been tested under AIX, Linux, Mac OS X and Windows XP - 7.
This package is licensed unter BSD-3.
AMG: "NaCl" also refers to Google Chrome's Native Client sandbox. See NaTcl.
NaCl is an unfortunate choice of name, it conflicts with Google's "Native Client" (NaCl) library https://www.chromium.org/nativeclient which could well use a Tcl interface to enable full standard Tcl to run "native" within a browser at normal compiled speeds, and as such, we might prefer to rename this newer piece of software since Native Client has been around a while and probably has prior claim. Larry Smith
(2016-08-22) Note: according to Wikipedia, the NaCl crypto library has prior claim: 2008 vs. 2011 for Google's Native Client.
EMJ - 2016-08-22: See also http://nacl.cr.yp.to/ .
(2021-07-29) Google Native Client was deprecated in 2020, and de-supported in June 2021. It's dead, while this NaCl cryptography library is still alive, so concerns about any potential naming conflict now belong in the past.
nacl - tcl package for Networking and Cryptography library (pronounced "salt")
Public-key cryptography
Secret-key cryptography
Low-level functions
NaCl (pronounced "salt") is a new easy-to-use high-speed software library for network communication, encryption, decryption, signatures, etc. NaCl's goal is to provide all of the core operations needed to build higher-level cryptographic tools. Of course, other libraries already exist for these core operations. NaCl advances the state of the art by improving security, by improving usability, and by improving speed.
No data flow from secrets to load addresses. No data flow from secrets to branch conditions. No padding oracles. Centralizing randomness. Avoiding unnecessary randomness. Extremely high speed.
Simple NaCl applications need only six high-level NaCl functions: crypto_box for public-key authenticated encryption; crypto_box_open for verification and decryption; crypto_box_keypair to create a public key in the first place; and similarly for signatures crypto_sign, crypto_sign_open, and crypto_sign_keypair.
A minimalist implementation of the NaCl API would provide just these six functions. TweetNaCl is more ambitious, supporting all 25 of the NaCl functions listed below, which as mentioned earlier are all of the C NaCl functions used by applications. This list includes all of NaCl's "default" primitives except for crypto_auth_hmacsha512256, which was included in NaCl only for compatibility with standards and is superseded by crypto_onetimeauth.
The Ed25519 signature system has not yet been integrated into NaCl, since the Ed25519 software has not yet been fully audited; NaCl currently provides an older signature system. However, NaCl has announced that it will transition to Ed25519, so TweetNaCl provides Ed25519.
Public-key cryptography
Secret-key cryptography
Low-level functions
How does crypto_box work?
What happens if you use it multiple times?
If you take two fixed key-pairs, the result of the key exchange will always be the same.
But the symmetric part secret_box is secure even when you use a key several times, as long as you never reuse a nonce for that key, i.e. the (key, nonce) pair must be unique.
This property is pretty much the same for all modern authenticated stream ciphers, such as AES-GCM or XSalsa20-Poly1305.
Common ways to create a unique nonce are:
from http://stackoverflow.com/questions/13663604/questions-about-the-nacl-crypto-library
Public-key cryptography authenticated encryption using nacl::box
package require nacl nacl::box keypair pub1 sec1 nacl::box keypair pub2 sec2 set nonce [nacl::randombytes box -nonce] set message {My Secret Message} if {[nacl::box encrypted $message $nonce $pub2 $sec1] == 0} { if {[nacl::box open decrypted $encrypted $nonce $pub1 $sec2] == 0} { puts "message decrypted = '$decrypted'" } }
Public-key cryptography signatures using nacl::sign
package require nacl nacl::sign keypair pub sec set message {My Message} if {[nacl::sign encrypted $message $sec] == 0} { if {[nacl::sign verify decrypted $encrypted $pub] == 0} { puts "signed message decrypted = '$decrypted'" } }
Secret-key cryptography authenticated encryption using nacl::secretbox
package require nacl set key [nacl::randombytes secretbox -key] set nonce [nacl::randombytes secretbox -nonce] set message {My Secret Message} if {[nacl::secretbox encrypted $message $nonce $key] == 0} { if {[nacl::secretbox open decrypted $encrypted $nonce $key] == 0} { puts "message decrypted = '$decrypted'" } }
Secret-key cryptography encryption using nacl::stream
package require nacl set key [nacl::randombytes stream -key] set nonce [nacl::randombytes stream -nonce] set message {My Secret Message} if {[nacl::stream encrypted $message $nonce $key] == 0} { if {[nacl::stream decrypted $encrypted $nonce $key] == 0} { puts "message decrypted = '$decrypted'" } }
Secret-key cryptography authentication using nacl::auth
package require nacl set key [nacl::randombytes auth -key] set message {My Message} if {[nacl::auth -hmac512256 auth $message $key] == 0} { if {[nacl::auth verify -hmac512256 $auth $message $key] == 0} { puts {authentication OK} } }
Secret-key cryptography one-time authentication using nacl::onetimeauth
package require nacl set key [nacl::randombytes onetimeauth -key] set message {My Message} if {[nacl::onetimeauth auth $message $key] == 0} { if {[nacl::onetimeauth verify $auth $message $key] == 0} { puts {one-time authentication OK} } }
Hashing using nacl::hash
package require nacl if {[nacl::hash -sha256 hash {NaCl does SHA256}] == 0} { }
or
package require nacl if {[nacl::hash -sha512 hash {NaCl does SHA512}] == 0} { }
WEB: nacl.cr.yp.to 20110221 [L1 ]
PDF: The security impact of a new cryptographic library [L2 ]
WEB: tweetnacl.cr.yp.to 20140427 [L3 ]
PDF: TweetNaCl: A crypto library in 100 tweets [L4 ]
WEB: en.wikipedia.org/wiki/NaCl_(software) [L5 ]
WEB: en.wikipedia.org/wiki/Elliptic_curve_cryptography [L6 ]
WEB: en.wikipedia.org/wiki/Curve25519 [L7 ]
WEB: RFC-7905: ChaCha20-Poly1305 Cipher Suites for Transport Layer Security (TLS) [L8 ]
WEB: RFC-8410: Algorithm Identifiers for Ed25519, Ed448, X25519, and X448 for Use in the Internet X.509 Public Key Infrastructure [L9 ]
WEB: BAWT Build Automation With Tcl / Batteries included [L10 ]
Copyright (C) 2016 Alexander Schoepe, Bochum, DE
NaCl and TweetNaCl crypto library are public domain and the Tcl package BSD-3 license
Contributors (alphabetical order)
Daniel J. Bernstein, University of Illinois at Chicago and Technische Universiteit Eindhoven
Bernard van Gastel, Radboud Universiteit Nijmegen
Wesley Janssen, Radboud Universiteit Nijmegen
Tanja Lange, Technische Universiteit Eindhoven
Peter Schwabe, Radboud Universiteit Nijmegen
Sjaak Smetsers, Radboud Universiteit Nijmegen