xref: /openssl/crypto/hmac/hmac_local.h (revision 0499de5a)
1 /*
2  * Copyright 1995-2024 The OpenSSL Project Authors. All Rights Reserved.
3  *
4  * Licensed under the Apache License 2.0 (the "License").  You may not use
5  * this file except in compliance with the License.  You can obtain a copy
6  * in the file LICENSE in the source distribution or at
7  * https://www.openssl.org/source/license.html
8  */
9 
10 #ifndef OSSL_CRYPTO_HMAC_LOCAL_H
11 # define OSSL_CRYPTO_HMAC_LOCAL_H
12 
13 # include "internal/common.h"
14 # include "internal/numbers.h"
15 # include "openssl/sha.h"
16 
17 /* The current largest case is for SHA3-224 */
18 #define HMAC_MAX_MD_CBLOCK_SIZE     144
19 
20 struct hmac_ctx_st {
21     const EVP_MD *md;
22     EVP_MD_CTX *md_ctx;
23     EVP_MD_CTX *i_ctx;
24     EVP_MD_CTX *o_ctx;
25 
26     /* Platform specific data */
27     union {
28         int dummy;
29 # ifdef OPENSSL_HMAC_S390X
30         struct {
31             unsigned int fc; /* 0 if not supported by kmac instruction */
32             int blk_size;
33             int ikp;
34             int iimp;
35             unsigned char *buf;
36             size_t size; /* must be multiple of digest block size */
37             size_t num;
38             union {
39                 OSSL_UNION_ALIGN;
40                 struct {
41                     uint32_t h[8];
42                     uint64_t imbl;
43                     unsigned char key[64];
44                 } hmac_224_256;
45                 struct {
46                     uint64_t h[8];
47                     uint128_t imbl;
48                     unsigned char key[128];
49                 } hmac_384_512;
50             } param;
51         } s390x;
52 # endif /* OPENSSL_HMAC_S390X */
53     } plat;
54 };
55 
56 # ifdef OPENSSL_HMAC_S390X
57 #  define HMAC_S390X_BUF_NUM_BLOCKS 64
58 
59 int s390x_HMAC_init(HMAC_CTX *ctx, const void *key, int key_len, ENGINE *impl);
60 int s390x_HMAC_update(HMAC_CTX *ctx, const unsigned char *data, size_t len);
61 int s390x_HMAC_final(HMAC_CTX *ctx, unsigned char *md, unsigned int *len);
62 int s390x_HMAC_CTX_copy(HMAC_CTX *dctx, HMAC_CTX *sctx);
63 int s390x_HMAC_CTX_cleanup(HMAC_CTX *ctx);
64 # endif /* OPENSSL_HMAC_S390X */
65 
66 #endif
67