XMSS Library
signing.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 
14 #pragma once
15 
16 #ifndef XMSS_SIGNING_H_INCLUDED
18 #define XMSS_SIGNING_H_INCLUDED
19 
20 #include "structures.h"
21 #include "types.h"
22 
23 /* === Library initialization === */
24 
96  XmssReallocFunction custom_realloc, XmssFreeFunction custom_free, XmssZeroizeFunction zeroize);
97 
98 /* === Key loading === */
99 
139  const XmssPrivateKeyStatefulBlob *key_usage, const XmssSigningContext *context);
140 
179  const XmssPublicKeyInternalBlob *public_key);
180 
181 /* === Key generation === */
182 
234  XmssPrivateKeyStatefulBlob **key_usage, const XmssBuffer *secure_random,
235  XmssIndexObfuscationSetting index_obfuscation_setting, const XmssBuffer *random, const XmssSigningContext *context);
236 
333  XmssInternalCache **generation_cache, const XmssKeyContext *key_context, XmssCacheType cache_type,
334  uint8_t cache_level, uint32_t generation_partitions);
335 
356 XmssError xmss_calculate_public_key_part(XmssKeyGenerationContext *generation_buffer, uint32_t partition_index);
357 
387  XmssKeyGenerationContext **generation_buffer, XmssKeyContext *key_context);
388 
389 /* === Signing === */
390 
426  uint32_t signature_count);
427 
458 XmssError xmss_sign_message(XmssSignatureBlob **signature, XmssKeyContext *key_context, const XmssBuffer *message);
459 
460 /* === Signature space partitioning === */
461 
513  XmssPrivateKeyStatefulBlob **updated_current_partition, XmssKeyContext *key_context, uint32_t new_partition_size);
514 
553  const XmssPrivateKeyStatefulBlob *partition_extension);
554 
555 /* === Informationals === */
556 
576 XmssError xmss_get_signature_count(size_t *total_count, size_t *remaining_count, const XmssKeyContext *key_context);
577 
605  const XmssPrivateKeyStatelessBlob *private_key, const XmssKeyContext *key_context);
606 
627  const XmssSigningContext *context);
628 
659  const XmssPrivateKeyStatelessBlob *private_key, const XmssKeyContext *key_context,
660  const XmssSigningContext *signing_context);
661 
678 XmssError xmss_get_caching_in_public_key(XmssCacheType *cache_type, uint32_t *cache_level,
679  const XmssPublicKeyInternalBlob *pub_key);
680 
681 /* === Exportable public key === */
682 
701 XmssError xmss_export_public_key(XmssPublicKey *exported_pub_key, const XmssKeyContext *key_context);
702 
721 XmssError xmss_verify_exported_public_key(const XmssPublicKey *exported_pub_key, const XmssKeyContext *key_context);
722 
723 #endif /* !XMSS_SIGNING_H_INCLUDED */
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
struct XmssKeyContext XmssKeyContext
Context for using the signature generation part of the library, with a loaded private key partition.
Definition: opaque_structures.h:123
XmssError xmss_verify_private_key_stateful(const XmssPrivateKeyStatefulBlob *key_usage, const XmssPrivateKeyStatelessBlob *private_key, const XmssKeyContext *key_context, const XmssSigningContext *signing_context)
Verify the validity and integrity of a stateful private key partition part.
XmssError xmss_sign_message(XmssSignatureBlob **signature, XmssKeyContext *key_context, const XmssBuffer *message)
Create a signature for a message.
XmssError xmss_verify_private_key_stateless(const XmssPrivateKeyStatelessBlob *private_key, const XmssSigningContext *context)
Verify the validity and integrity of a stateless private key part.
XmssError xmss_context_initialize(XmssSigningContext **context, XmssParameterSetOID parameter_set, XmssReallocFunction custom_realloc, XmssFreeFunction custom_free, XmssZeroizeFunction zeroize)
Initialize a new instantiation of the signature key and generation library.
XmssError xmss_load_public_key(XmssInternalCache **cache, XmssKeyContext *key_context, const XmssPublicKeyInternalBlob *public_key)
Load a public key from storage.
XmssError xmss_calculate_public_key_part(XmssKeyGenerationContext *generation_buffer, uint32_t partition_index)
Perform work on an ongoing public key calculation.
XmssError xmss_verify_public_key(const XmssPublicKeyInternalBlob *pub_key, const XmssPrivateKeyStatelessBlob *private_key, const XmssKeyContext *key_context)
Verify the validity and integrity of a public key blob.
XmssError xmss_get_caching_in_public_key(XmssCacheType *cache_type, uint32_t *cache_level, const XmssPublicKeyInternalBlob *pub_key)
Extract the level of the cache that is stored in a public key blob.
XmssError xmss_generate_private_key(XmssKeyContext **key_context, XmssPrivateKeyStatelessBlob **private_key, XmssPrivateKeyStatefulBlob **key_usage, const XmssBuffer *secure_random, XmssIndexObfuscationSetting index_obfuscation_setting, const XmssBuffer *random, const XmssSigningContext *context)
Generate a new private key.
XmssError xmss_generate_public_key(XmssKeyGenerationContext **generation_buffer, XmssInternalCache **cache, XmssInternalCache **generation_cache, const XmssKeyContext *key_context, XmssCacheType cache_type, uint8_t cache_level, uint32_t generation_partitions)
Set up the process of generating the public key.
XmssError xmss_partition_signature_space(XmssPrivateKeyStatefulBlob **new_partition, XmssPrivateKeyStatefulBlob **updated_current_partition, XmssKeyContext *key_context, uint32_t new_partition_size)
Partition a private key into two private keys.
XmssError xmss_merge_signature_space(XmssPrivateKeyStatefulBlob **new_key_usage, XmssKeyContext *key_context, const XmssPrivateKeyStatefulBlob *partition_extension)
Merge two partitions of a private key into one private key partition.
XmssError xmss_get_signature_count(size_t *total_count, size_t *remaining_count, const XmssKeyContext *key_context)
The number of signatures that can still be created with a private key partition.
XmssError xmss_finish_calculate_public_key(XmssPublicKeyInternalBlob **public_key, XmssKeyGenerationContext **generation_buffer, XmssKeyContext *key_context)
Finalize calculation on a public key.
XmssError xmss_verify_exported_public_key(const XmssPublicKey *exported_pub_key, const XmssKeyContext *key_context)
Verify the correctness of an exported public key.
XmssError xmss_export_public_key(XmssPublicKey *exported_pub_key, const XmssKeyContext *key_context)
Write the public key to an exportable format.
XmssError xmss_request_future_signatures(XmssPrivateKeyStatefulBlob **new_key_usage, XmssKeyContext *key_context, uint32_t signature_count)
Request permission to sign one or more messages.
XmssError xmss_load_private_key(XmssKeyContext **key_context, const XmssPrivateKeyStatelessBlob *private_key, const XmssPrivateKeyStatefulBlob *key_usage, const XmssSigningContext *context)
Load a private key partition from storage.
A pointer to a buffer with a given size.
Definition: types.h:329
A stored stateful private key part.
Definition: structures.h:66
A stored stateless private key part.
Definition: structures.h:39
A stored public key for the signing library.
Definition: structures.h:94
Exportable format for a public key.
Definition: structures.h:126
Structure that embeds the exportable format for a signature, along with the signature's data size.
Definition: structures.h:194
XMSS library specific structured types.
Enumerations, basic types and callback function specifications.
void(* XmssFreeFunction)(void *ptr)
A function to deallocate memory.
Definition: types.h:371
XmssError
The return codes for the functions in the XMSS library.
Definition: types.h:103
XmssCacheType
The type of caching to use.
Definition: types.h:241
void(* XmssZeroizeFunction)(void *ptr, size_t size)
A function to securely erase sensitive data.
Definition: types.h:383
XmssIndexObfuscationSetting
The supported settings for index obfuscation.
Definition: types.h:228
XmssParameterSetOID
The XMSS parameter sets that are supported by this library.
Definition: types.h:186
void *(* XmssReallocFunction)(void *ptr, size_t size)
A function to reallocate memory.
Definition: types.h:354