Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:02:16

0001 /* streebog.h
0002 
0003    The Streebog family of hash functions.
0004 
0005    Copyright (C) 2020 Dmitry Baryshkov
0006 
0007    This file is part of GNU Nettle.
0008 
0009    GNU Nettle is free software: you can redistribute it and/or
0010    modify it under the terms of either:
0011 
0012      * the GNU Lesser General Public License as published by the Free
0013        Software Foundation; either version 3 of the License, or (at your
0014        option) any later version.
0015 
0016    or
0017 
0018      * the GNU General Public License as published by the Free
0019        Software Foundation; either version 2 of the License, or (at your
0020        option) any later version.
0021 
0022    or both in parallel, as here.
0023 
0024    GNU Nettle is distributed in the hope that it will be useful,
0025    but WITHOUT ANY WARRANTY; without even the implied warranty of
0026    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0027    General Public License for more details.
0028 
0029    You should have received copies of the GNU General Public License and
0030    the GNU Lesser General Public License along with this program.  If
0031    not, see http://www.gnu.org/licenses/.
0032 */
0033  
0034 #ifndef NETTLE_STREEBOG_H_INCLUDED
0035 #define NETTLE_STREEBOG_H_INCLUDED
0036 
0037 #include "nettle-types.h"
0038 
0039 #ifdef __cplusplus
0040 extern "C" {
0041 #endif
0042 
0043 /* Name mangling */
0044 #define streebog256_init nettle_streebog256_init
0045 #define streebog256_digest nettle_streebog256_digest
0046 #define streebog512_init nettle_streebog512_init
0047 #define streebog512_update nettle_streebog512_update
0048 #define streebog512_digest nettle_streebog512_digest
0049 
0050 /* STREEBOG512 */
0051 
0052 #define STREEBOG512_DIGEST_SIZE 64
0053 #define STREEBOG512_BLOCK_SIZE 64
0054 
0055 /* Digest is kept internally as 8 64-bit words. */
0056 #define _STREEBOG512_DIGEST_LENGTH 8
0057 
0058 struct streebog512_ctx
0059 {
0060   uint64_t state[_STREEBOG512_DIGEST_LENGTH];    /* State variables */
0061   uint64_t count[_STREEBOG512_DIGEST_LENGTH];
0062   uint64_t sigma[_STREEBOG512_DIGEST_LENGTH];
0063   unsigned int index;                       /* index into buffer */
0064   uint8_t block[STREEBOG512_BLOCK_SIZE];          /* STREEBOG512 data buffer */
0065 };
0066 
0067 void
0068 streebog512_init(struct streebog512_ctx *ctx);
0069 
0070 void
0071 streebog512_update(struct streebog512_ctx *ctx,
0072           size_t length,
0073           const uint8_t *data);
0074 
0075 void
0076 streebog512_digest(struct streebog512_ctx *ctx,
0077           size_t length,
0078           uint8_t *digest);
0079 
0080 
0081 #define STREEBOG256_DIGEST_SIZE 32
0082 #define STREEBOG256_BLOCK_SIZE STREEBOG512_BLOCK_SIZE
0083 #define streebog256_ctx streebog512_ctx
0084 
0085 void
0086 streebog256_init(struct streebog256_ctx *ctx);
0087 
0088 #define streebog256_update nettle_streebog512_update
0089 
0090 void
0091 streebog256_digest(struct streebog256_ctx *ctx,
0092           size_t length,
0093           uint8_t *digest);
0094 
0095 #ifdef __cplusplus
0096 }
0097 #endif
0098 
0099 #endif /* NETTLE_STREEBOG_H_INCLUDED */