XMSS Library
opaque_structures.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: 2022 Fox Crypto B.V.
3  * SPDX-License-Identifier: MIT
4  *
5  * SPDX-FileContributor: Thomas Schaap
6  */
7 
17 #pragma once
18 
19 #ifndef XMSS_OPAQUE_STRUCTURES_H_INCLUDED
21 #define XMSS_OPAQUE_STRUCTURES_H_INCLUDED
22 
23 #include "types.h"
24 #include "compat.h"
25 
38 
43 #define XMSS_SIGNING_CONTEXT_SIZE (4u + 4u + 4u + 4u + 4u * sizeof(void(*)(void)))
44 
57 
68 
80 #define XMSS_CACHE_ENTRY_COUNT(cache_type, cache_level, param_set) \
81  ((cache_type) == XMSS_CACHE_NONE ? 0u : \
82  ((cache_level) >= XMSS_TREE_DEPTH(param_set) ? 0u : \
83  ((cache_type) == XMSS_CACHE_SINGLE_LEVEL ? (1u << (XMSS_TREE_DEPTH(param_set) - (cache_level))) : \
84  ((cache_type) == XMSS_CACHE_TOP ? ((1u << ((XMSS_TREE_DEPTH(param_set) - (cache_level)) + 1u)) - 1u) : \
85  0u /* Garbage in, 0 out. */ \
86  ) \
87  ) \
88  ) \
89  )
90 
102 #define XMSS_INTERNAL_CACHE_SIZE(cache_type, cache_level, param_set) \
103  (4 + 4 + sizeof(XmssValue256) * XMSS_CACHE_ENTRY_COUNT((cache_type), (cache_level), (param_set)))
104 
111 #define XMSS_PUBLIC_KEY_GENERATION_CACHE_SIZE(number_of_partitions) \
112  (4 + 4 + sizeof(XmssValue256) * (number_of_partitions))
113 
123 typedef struct XmssKeyContext XmssKeyContext;
124 
132 #define XMSS_PRIVATE_KEY_STATEFUL_PART_SIZE (4u + 4u)
133 
141 #define XMSS_PRIVATE_KEY_STATELESS_PART_SIZE (32u + 32u + 4u + 4u + 32u + sizeof(XmssValue256) + 32u)
142 
152 #define XMSS_KEY_CONTEXT_SIZE(param_set, obfuscation_setting) \
153  (4u + 4u + XMSS_SIGNING_CONTEXT_SIZE + XMSS_PRIVATE_KEY_STATELESS_PART_SIZE + \
154  2u * XMSS_PRIVATE_KEY_STATEFUL_PART_SIZE + 3 * sizeof(XmssValue256) + sizeof(void*) + 4u + 4u + \
155  4u * (1u << XMSS_TREE_DEPTH(param_set)) * ((obfuscation_setting) == XMSS_INDEX_OBFUSCATION_ON ? 1u : 0u))
156 
167 
182 
190 #define XMSS_KEY_GENERATION_CONTEXT_SIZE(generation_partitions) \
191  (sizeof(void*) + sizeof(uint32_t) + sizeof(uint32_t) + sizeof(void*) + sizeof(void*) + \
192  sizeof(uint32_t) * (generation_partitions))
193 
205 
206 #endif /* !XMSS_OPAQUE_STRUCTURES_H_INCLUDED */
C99 compatibility layer.
void xmss_free_key_generation_context(XmssKeyGenerationContext *key_generation_context)
Deallocate an XmssKeyGenerationContext structure.
void xmss_free_signing_context(XmssSigningContext *signing_context)
Deallocate an XmssSigningContext structure.
struct XmssSigningContext XmssSigningContext
The context of an instantiation of the signing library.
Definition: opaque_structures.h:37
struct XmssKeyGenerationContext XmssKeyGenerationContext
The temporary context to gather all the results of generating a public key.
Definition: opaque_structures.h:181
struct XmssInternalCache XmssInternalCache
In-memory representation of a loaded cache.
Definition: opaque_structures.h:67
void xmss_free_key_context(XmssKeyContext *key_context)
Deallocate an XmssKeyContext structure.
struct XmssKeyContext XmssKeyContext
Context for using the signature generation part of the library, with a loaded private key partition.
Definition: opaque_structures.h:123
Enumerations, basic types and callback function specifications.