From 356e37cb9cceeca82df50ef99b68979eb3ff0136 Mon Sep 17 00:00:00 2001 From: Laurent Bercot Date: Thu, 29 May 2025 23:30:35 +0000 Subject: Add crc32c. Prepare for 2.14.5.0 Signed-off-by: Laurent Bercot --- doc/libstdcrypto/index.html | 82 +++++++++++++++++++-------------------------- 1 file changed, 35 insertions(+), 47 deletions(-) (limited to 'doc/libstdcrypto') diff --git a/doc/libstdcrypto/index.html b/doc/libstdcrypto/index.html index 6bf6974..d7c2bc0 100644 --- a/doc/libstdcrypto/index.html +++ b/doc/libstdcrypto/index.html @@ -26,16 +26,16 @@ operations are provided:

- Please bear in mind that rc4 and md5 are broken, and that sha1 is about to be. -Do not use them in security-critical applications. + Please bear in mind that sha1 is practically broken. +Do not use it in security-critical applications.

Compiling

@@ -51,49 +51,6 @@ Do not use them in security-critical applications. for the exact function prototypes.

-

-RC4

- -
-  RC4Schedule ctx ;
-  unsigned char const *key ;
-  size_t keylen ;
-  unsigned char const *in ;
-  unsigned char *out ;
-  size_t len ;
-
-  rc4_init(&ctx, key, keylen) ;
-  rc4(&ctx, in, out, len) ;
-
- -
    -
  • rc4_init() initializes a RC4Schedule structure with a key key, -of length keylen. It then computes and throws away the first RC4_THROWAWAY -bytes, usually 100
  • -
  • rc4() encrypts len bytes of in with the RC4 flow, and -stores the results into out
  • -
- -

-MD5

- -
-  MD5Schedule ctx ;
-  char const *message ;
-  size_t messagelen ;
-  char digest[16] ;
-
-  md5_init(&ctx) ;
-  md5_update(&ctx, message, messagelen) ;
-  md5_final(&ctx, digest) ;
-
- -
    -
  • md5_init() prepares a MD5Schedule structure for computation
  • -
  • md5_update() adds message to the message to be digested
  • -
  • md5_final() computes the digest
  • -
-

SHA1

@@ -154,5 +111,36 @@ SHA512
  • sha512_final() computes the digest
  • +

    +blake2s

    + + Same scheme as with the other hashes. + +
    +  blake2s_ctx ctx ;
    +  char const *message ;
    +  size_t messagelen ;
    +  size_t outlen = 32 ;  /* the user gives the length of the digest */
    +  char digest[outlen] ;
    +
    +  blake2s_init(&ctx, outlen) ;
    +  blake2s_update(&ctx, message, messagelen) ;
    +  blake2s_final(&ctx, digest) ;
    +
    + +

    +crc32c

    + + This isn't a cryptography primitive, but just a function to compute +the Castagnoli version of a cyclic redundancy code. + +
    +  uint32_t crc = 0 ;  /* no need for context except that crc needs to be initialized to 0 */
    +  char const *message ;
    +  size_t messagelen ;
    +
    +  crc = crc32c(crc, message, messagelen) ;
    +
    + -- cgit v1.3.1