The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/contrib/openzfs/lib/libspl/include/sys/sha2.h

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*
    2  * CDDL HEADER START
    3  *
    4  * The contents of this file are subject to the terms of the
    5  * Common Development and Distribution License (the "License").
    6  * You may not use this file except in compliance with the License.
    7  *
    8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
    9  * or https://opensource.org/licenses/CDDL-1.0.
   10  * See the License for the specific language governing permissions
   11  * and limitations under the License.
   12  *
   13  * When distributing Covered Code, include this CDDL HEADER in each
   14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
   15  * If applicable, add the following below this CDDL HEADER, with the
   16  * fields enclosed by brackets "[]" replaced with your own identifying
   17  * information: Portions Copyright [yyyy] [name of copyright owner]
   18  *
   19  * CDDL HEADER END
   20  */
   21 /*
   22  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
   23  * Use is subject to license terms.
   24  */
   25 /* Copyright 2013 Saso Kiselkov.  All rights reserved. */
   26 
   27 #ifndef _SYS_SHA2_H
   28 #define _SYS_SHA2_H
   29 
   30 #include <stdint.h>
   31 
   32 #ifdef  __cplusplus
   33 extern "C" {
   34 #endif
   35 
   36 #define SHA256_DIGEST_LENGTH    32      /* SHA256 digest length in bytes */
   37 #define SHA384_DIGEST_LENGTH    48      /* SHA384 digest length in bytes */
   38 #define SHA512_DIGEST_LENGTH    64      /* SHA512 digest length in bytes */
   39 
   40 /* Truncated versions of SHA-512 according to FIPS-180-4, section 5.3.6 */
   41 #define SHA512_224_DIGEST_LENGTH        28      /* SHA512/224 digest length */
   42 #define SHA512_256_DIGEST_LENGTH        32      /* SHA512/256 digest length */
   43 
   44 #define SHA256_HMAC_BLOCK_SIZE  64      /* SHA256-HMAC block size */
   45 #define SHA512_HMAC_BLOCK_SIZE  128     /* SHA512-HMAC block size */
   46 
   47 #define SHA256                  0
   48 #define SHA256_HMAC             1
   49 #define SHA256_HMAC_GEN         2
   50 #define SHA384                  3
   51 #define SHA384_HMAC             4
   52 #define SHA384_HMAC_GEN         5
   53 #define SHA512                  6
   54 #define SHA512_HMAC             7
   55 #define SHA512_HMAC_GEN         8
   56 #define SHA512_224              9
   57 #define SHA512_256              10
   58 
   59 /*
   60  * SHA2 context.
   61  * The contents of this structure are a private interface between the
   62  * Init/Update/Final calls of the functions defined below.
   63  * Callers must never attempt to read or write any of the fields
   64  * in this structure directly.
   65  */
   66 typedef struct  {
   67         uint32_t algotype;              /* Algorithm Type */
   68 
   69         /* state (ABCDEFGH) */
   70         union {
   71                 uint32_t s32[8];        /* for SHA256 */
   72                 uint64_t s64[8];        /* for SHA384/512 */
   73         } state;
   74         /* number of bits */
   75         union {
   76                 uint32_t c32[2];        /* for SHA256 , modulo 2^64 */
   77                 uint64_t c64[2];        /* for SHA384/512, modulo 2^128 */
   78         } count;
   79         union {
   80                 uint8_t         buf8[128];      /* undigested input */
   81                 uint32_t        buf32[32];      /* realigned input */
   82                 uint64_t        buf64[16];      /* realigned input */
   83         } buf_un;
   84 } SHA2_CTX;
   85 
   86 typedef SHA2_CTX SHA256_CTX;
   87 typedef SHA2_CTX SHA384_CTX;
   88 typedef SHA2_CTX SHA512_CTX;
   89 
   90 extern void SHA256Init(SHA256_CTX *);
   91 
   92 extern void SHA256Update(SHA256_CTX *, const void *, size_t);
   93 
   94 extern void SHA256Final(void *, SHA256_CTX *);
   95 
   96 extern void SHA384Init(SHA384_CTX *);
   97 
   98 extern void SHA384Update(SHA384_CTX *, const void *, size_t);
   99 
  100 extern void SHA384Final(void *, SHA384_CTX *);
  101 
  102 extern void SHA512Init(SHA512_CTX *);
  103 
  104 extern void SHA512Update(SHA512_CTX *, const void *, size_t);
  105 
  106 extern void SHA512Final(void *, SHA512_CTX *);
  107 
  108 extern void SHA2Init(uint64_t mech, SHA2_CTX *);
  109 
  110 extern void SHA2Update(SHA2_CTX *, const void *, size_t);
  111 
  112 extern void SHA2Final(void *, SHA2_CTX *);
  113 
  114 #ifdef _SHA2_IMPL
  115 /*
  116  * The following types/functions are all private to the implementation
  117  * of the SHA2 functions and must not be used by consumers of the interface
  118  */
  119 
  120 /*
  121  * List of support mechanisms in this module.
  122  *
  123  * It is important to note that in the module, division or modulus calculations
  124  * are used on the enumerated type to determine which mechanism is being used;
  125  * therefore, changing the order or additional mechanisms should be done
  126  * carefully
  127  */
  128 typedef enum sha2_mech_type {
  129         SHA256_MECH_INFO_TYPE,          /* SUN_CKM_SHA256 */
  130         SHA256_HMAC_MECH_INFO_TYPE,     /* SUN_CKM_SHA256_HMAC */
  131         SHA256_HMAC_GEN_MECH_INFO_TYPE, /* SUN_CKM_SHA256_HMAC_GENERAL */
  132         SHA384_MECH_INFO_TYPE,          /* SUN_CKM_SHA384 */
  133         SHA384_HMAC_MECH_INFO_TYPE,     /* SUN_CKM_SHA384_HMAC */
  134         SHA384_HMAC_GEN_MECH_INFO_TYPE, /* SUN_CKM_SHA384_HMAC_GENERAL */
  135         SHA512_MECH_INFO_TYPE,          /* SUN_CKM_SHA512 */
  136         SHA512_HMAC_MECH_INFO_TYPE,     /* SUN_CKM_SHA512_HMAC */
  137         SHA512_HMAC_GEN_MECH_INFO_TYPE, /* SUN_CKM_SHA512_HMAC_GENERAL */
  138         SHA512_224_MECH_INFO_TYPE,      /* SUN_CKM_SHA512_224 */
  139         SHA512_256_MECH_INFO_TYPE       /* SUN_CKM_SHA512_256 */
  140 } sha2_mech_type_t;
  141 
  142 #endif /* _SHA2_IMPL */
  143 
  144 #ifdef  __cplusplus
  145 }
  146 #endif
  147 
  148 #endif /* _SYS_SHA2_H */

Cache object: 48e6b5321535a1347a1d580f13363c4a


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.