commit 451e953eb40ea49a25ef48a2c30274a76c78420c
parent e8655af4fc9dfbe8407e7c5477d8ec3a286a006a
Author: Drew DeVault <sir@cmpwn.com>
Date: Wed, 21 Apr 2021 11:49:36 -0400
crypto: docs improvements
Diffstat:
5 files changed, 15 insertions(+), 16 deletions(-)
diff --git a/crypto/md5/md5.ha b/crypto/md5/md5.ha
@@ -3,7 +3,7 @@ use io;
use crypto::math;
use endian;
-// The size, in bytes, of a MD5 digest.
+// The size, in bytes, of an MD5 digest.
export def SIZE: size = 16;
def chunk: size = 64;
@@ -20,10 +20,10 @@ type digest = struct {
ln: size,
};
-// Creates a [[hash::hash]] which computes a MD5 hash as defined in RFC 1321. Note
-// that MD5 is cryptographically broken and should not be used for secure
-// applications. Where possible, applications are encouraged to use [[sha256]] or
-// [[sha512]] instead.
+// Creates a [[hash::hash]] which computes a MD5 hash as defined in RFC 1321.
+// Note that MD5 is cryptographically broken and should not be used for secure
+// applications. Where possible, applications are encouraged to use [[sha256]]
+// or [[sha512]] instead.
export fn md5() *hash::hash = {
let md5 = alloc(digest {
hash = hash::hash {
diff --git a/crypto/sha1/sha1.ha b/crypto/sha1/sha1.ha
@@ -23,9 +23,9 @@ type digest = struct {
ln: size,
};
-// Creates a [[hash::hash]] which computes a SHA-1 hash. Note that this alogorithm
-// is no longer considered secure. Where possible, applications are encouraged
-// to use [[sha256]] or [[sha512]] instead.
+// Creates a [[hash::hash]] which computes a SHA-1 hash. Note that this
+// alogorithm is no longer considered secure. Where possible, applications are
+// encouraged to use [[sha256]] or [[sha512]] instead.
export fn sha1() *hash::hash = {
let sha = alloc(digest {
hash = hash::hash {
diff --git a/crypto/sha256/sha256.ha b/crypto/sha256/sha256.ha
@@ -6,7 +6,7 @@ use io;
// The size, in bytes, of a SHA-256 digest.
export def SIZE: size = 32;
-// Loosely based on the Go implementation
+// This is loosely based on the Go implementation
def chunk: size = 64;
def init0: u32 = 0x6A09E667;
def init1: u32 = 0xBB67AE85;
diff --git a/crypto/sha512/README b/crypto/sha512/README
@@ -0,0 +1,2 @@
+The sha512 module implements the SHA-384, SHA-512, SHA-512/224, and SHA-512/256
+hash algorithms as defined in FIPS 180-4.
diff --git a/crypto/sha512/sha512.ha b/crypto/sha512/sha512.ha
@@ -3,9 +3,6 @@ use endian;
use hash;
use io;
-// Package sha512 implements the SHA-384, SHA-512, SHA-512/224, and SHA-512/256
-// hash algorithms as defined in FIPS 180-4.
-
type variant = enum {
SHA384,
SHA512,
@@ -13,16 +10,16 @@ type variant = enum {
SHA512_256,
};
-// The size, in bytes, of the SHA-512 checksum.
+// The size, in bytes, of a SHA-512 checksum.
export def SIZE: size = 64;
-// The size, in bytes, of the SHA-512/224 checksum.
+// The size, in bytes, of a SHA-512/224 checksum.
export def SIZE224: size = 28;
-// The size, in bytes, of the SHA-512/256 checksum.
+// The size, in bytes, of a SHA-512/256 checksum.
export def SIZE256: size = 32;
-// The size, in bytes, of the SHA-384 checksum.
+// The size, in bytes, of a SHA-384 checksum.
export def SIZE384: size = 48;
def chunk: size = 128;