Botan 3.11.0
Crypto and TLS for C&
ffi.h
Go to the documentation of this file.
1/*
2* FFI (C89 API)
3* (C) 2015,2017 Jack Lloyd
4* (C) 2021 René Fischer
5* (C) 2024,2025,2026 Amos Treiber, René Meusel, Rohde & Schwarz Cybersecurity
6*
7* Botan is released under the Simplified BSD License (see license.txt)
8*/
9
10#ifndef BOTAN_FFI_H_
11#define BOTAN_FFI_H_
12
13#ifdef __cplusplus
14extern "C" {
15#endif
16
17/*
18This header exports some of botan's functionality via a C89 interface. This API
19is used by the Python, OCaml, Rust, Ruby, and Haskell bindings via those languages
20respective ctypes/FFI libraries.
21
22The API is intended to be as easy as possible to call from other
23languages, which often have easy ways to call C, because C. But some C
24code is easier to deal with than others, so to make things easy this
25API follows a few simple rules:
26
27- All interactions are via pointers to opaque structs. No need to worry about
28 structure padding issues and the like.
29
30- All functions return an int error code (except the version calls, which are
31 assumed to always have something to say).
32
33- Use simple types: size_t for lengths, const char* NULL terminated strings,
34 uint8_t for binary.
35
36- No ownership of memory transfers across the API boundary. The API will consume
37 data from const pointers with specified lengths. Outputs are either placed into
38 buffers provided by (and allocated by) the caller, or are returned via a
39 callback (what the FFI layer calls "view" functions).
40
41 When writing to an application-provided buffer, the function takes a pointer
42 to the output array and a read/write pointer to the length. The length field
43 is always set to the actual amount of data that would have been written. If
44 the input buffer's size was insufficient an error is returned.
45
46 In many situations the length of the output can be known in advance without
47 difficulty, in which case there will be a function which allows querying the
48 expected output length. For example `botan_hash_output_length` allows knowing
49 in advance the expected size for `botan_hash_final`. Some of these are exact,
50 while others such as `botan_pk_op_decrypt_output_length` can only provide an
51 upper bound for various technical reasons.
52
53 In some cases knowing the exact size is difficult or impossible. In these
54 situations view functions are used; see the handbook for further details.
55
56 TODO: Doxygen comments for all parameters
57*/
58
59#include <stddef.h>
60#include <stdint.h>
61
62/* NOLINTBEGIN(*-macro-usage,*-misplaced-const) */
63
64/**
65* The compile time API version. This matches the value of
66* botan_ffi_api_version. This can be used for compile-time checking if a
67* particular feature is available.
68*
69* Note this same value is also reflected in BOTAN_HAS_FFI in build.h, however
70* that declaration is not visible here since this header is intentionally
71* free-standing, depending only on a few C standard library headers.
72*/
73#define BOTAN_FFI_API_VERSION 20260303
74
75/**
76* BOTAN_FFI_EXPORT indicates public FFI functions.
77*
78* The arguments to the macro are to indicate the version that
79* that particular FFI function was first available
80*/
81#if defined(BOTAN_DLL)
82 #define BOTAN_FFI_EXPORT(maj, min) BOTAN_DLL
83#else
84 #if defined(__has_attribute)
85 #if __has_attribute(visibility)
86 #define BOTAN_FFI_EXPORT(maj, min) __attribute__((visibility("default")))
87 #endif
88 #elif defined(_MSC_VER) && !defined(BOTAN_IS_BEING_BUILT)
89 #define BOTAN_FFI_EXPORT(maj, min) __declspec(dllimport)
90 #else
91 #define BOTAN_FFI_EXPORT(maj, min)
92 #endif
93#endif
94
95#if !defined(BOTAN_NO_DEPRECATED_WARNINGS) && !defined(BOTAN_AMALGAMATION_H_) && !defined(BOTAN_IS_BEING_BUILT)
96 #if defined(__has_attribute)
97 #if __has_attribute(deprecated)
98 #define BOTAN_FFI_DEPRECATED(msg) __attribute__((deprecated(msg)))
99 #endif
100 #elif defined(_MSC_VER)
101 #define BOTAN_FFI_DEPRECATED(msg) __declspec(deprecated(msg))
102 #endif
103#endif
104
105#if !defined(BOTAN_FFI_DEPRECATED)
106 #define BOTAN_FFI_DEPRECATED(msg) /**/
107#endif
108
109/**
110* Error codes
111*
112* If you add a new value here be sure to also add it in
113* botan_error_description
114*/
150
151/**
152* The application provided context for a view function
153*/
154typedef void* botan_view_ctx;
155
156/**
157* Viewer function for binary data
158*
159* @param view_ctx some application context
160* @param data the binary data
161* @param len the length of data in bytes
162*/
163typedef int (*botan_view_bin_fn)(botan_view_ctx view_ctx, const uint8_t* data, size_t len);
164
165/**
166* Viewer function for string data
167*
168* @param view_ctx some application context
169* @param str the null terminated string
170* @param len the length of string *including* the null terminator
171*/
172typedef int (*botan_view_str_fn)(botan_view_ctx view_ctx, const char* str, size_t len);
173
174/**
175* Convert an error code into a string. Returns "Unknown error"
176* if the error code is not a known one.
177*/
178BOTAN_FFI_EXPORT(2, 8) const char* botan_error_description(int err);
179
180/**
181* Return the message of the last exception caught in this thread.
182*
183* This pointer can/will be reallocated or overwritten the next time
184* this thread calls any other Botan FFI function and must be copied
185* to persistent storage first.
186*/
188
189/**
190* Return the version of the currently supported FFI API. This is
191* expressed in the form YYYYMMDD of the release date of this version
192* of the API.
193*/
194BOTAN_FFI_EXPORT(2, 0) uint32_t botan_ffi_api_version(void);
195
196/**
197* Return 0 (ok) if the version given is one this library supports.
198* botan_ffi_supports_api(botan_ffi_api_version()) will always return 0.
199*/
200BOTAN_FFI_EXPORT(2, 0) int botan_ffi_supports_api(uint32_t api_version);
201
202/**
203* Return a free-form version string, e.g., 2.0.0
204*/
205BOTAN_FFI_EXPORT(2, 0) const char* botan_version_string(void);
206
207/**
208* Return the major version of the library
209*/
210BOTAN_FFI_EXPORT(2, 0) uint32_t botan_version_major(void);
211
212/**
213* Return the minor version of the library
214*/
215BOTAN_FFI_EXPORT(2, 0) uint32_t botan_version_minor(void);
216
217/**
218* Return the patch version of the library
219*/
220BOTAN_FFI_EXPORT(2, 0) uint32_t botan_version_patch(void);
221
222/**
223* Return the date this version was released as an integer.
224*
225* Returns 0 if the library was not built from an official release
226*/
227BOTAN_FFI_EXPORT(2, 0) uint32_t botan_version_datestamp(void);
228
229/**
230* Returns 0 if x[0..len] == y[0..len], or otherwise -1
231*/
232BOTAN_FFI_EXPORT(2, 3) int botan_constant_time_compare(const uint8_t* x, const uint8_t* y, size_t len);
233
234/**
235* Deprecated equivalent to botan_constant_time_compare
236*/
237BOTAN_FFI_DEPRECATED("Use botan_constant_time_compare")
238BOTAN_FFI_EXPORT(2, 0) int botan_same_mem(const uint8_t* x, const uint8_t* y, size_t len);
239
240/**
241* Clear out memory using a system specific approach to bypass elision by the
242* compiler (currently using RtlSecureZeroMemory or tricks with volatile pointers).
243*/
244BOTAN_FFI_EXPORT(2, 2) int botan_scrub_mem(void* mem, size_t bytes);
245
246/**
247* Flag that can be provided to botan_hex_encode to request lower case hex
248*/
249#define BOTAN_FFI_HEX_LOWER_CASE 1
250
251/**
252* Perform hex encoding
253* @param x is some binary data
254* @param len length of x in bytes
255* @param out an array of at least x*2 bytes
256* @param flags flags out be upper or lower case?
257* @return 0 on success, a negative value on failure
258*/
259BOTAN_FFI_EXPORT(2, 0) int botan_hex_encode(const uint8_t* x, size_t len, char* out, uint32_t flags);
260
261/**
262* Perform hex decoding
263* @param hex_str a string of hex chars (whitespace is ignored)
264* @param in_len the length of hex_str
265* @param out the output buffer should be at least strlen(hex_str)/2 bytes
266* @param out_len the size of the output buffer on input, set to the number of bytes written
267* @return 0 on success, a negative value on failure
268*/
269BOTAN_FFI_EXPORT(2, 3) int botan_hex_decode(const char* hex_str, size_t in_len, uint8_t* out, size_t* out_len);
270
271/**
272* Perform base64 encoding
273*
274* @param x the input data
275* @param len the length of x
276* @param out the output buffer
277* @param out_len the size of the output buffer on input, set to the number of bytes written
278* @return 0 on success, a negative value on failure
279
280*/
281BOTAN_FFI_EXPORT(2, 3) int botan_base64_encode(const uint8_t* x, size_t len, char* out, size_t* out_len);
282
283/**
284* Perform base64 decoding
285*/
286BOTAN_FFI_EXPORT(2, 3) int botan_base64_decode(const char* base64_str, size_t in_len, uint8_t* out, size_t* out_len);
287
288/**
289* RNG type
290*/
291typedef struct botan_rng_struct* botan_rng_t;
292
293/**
294* Initialize a random number generator object
295* @param rng rng object
296* @param rng_type type of the rng, possible values:
297* "system": system RNG
298* "esdm-full": ESDM RNG (fully seeded)
299* "esdm-pr": ESDM RNG (w. prediction resistance)
300* "user": userspace RNG
301* "user-threadsafe": userspace RNG, with internal locking
302* "rdrand": directly read RDRAND
303* Set rng_type to null to let the library choose some default.
304*/
305BOTAN_FFI_EXPORT(2, 0) int botan_rng_init(botan_rng_t* rng, const char* rng_type);
306
307/**
308* Initialize a custom random number generator from a set of callback functions
309* @param rng_out rng object to create
310* @param rng_name name of the rng
311* @param context An application-specific context passed to the callback functions
312* @param get_cb Callback for getting random bytes from the rng, return 0 for success
313* @param add_entropy_cb Callback for adding entropy to the rng, return 0 for success, may be NULL
314* @param destroy_cb Callback called when rng is destroyed, may be NULL
315*/
318 const char* rng_name,
319 void* context,
320 int (*get_cb)(void* context, uint8_t* out, size_t out_len),
321 int (*add_entropy_cb)(void* context, const uint8_t input[], size_t length),
322 void (*destroy_cb)(void* context));
323
324/**
325* Get random bytes from a random number generator
326*
327* @param rng rng object
328* @param out output buffer of size out_len
329* @param out_len number of requested bytes
330* @return 0 on success, negative on failure
331*/
332BOTAN_FFI_EXPORT(2, 0) int botan_rng_get(botan_rng_t rng, uint8_t* out, size_t out_len);
333
334/**
335* Get random bytes from system random number generator
336*
337* @param out output buffer of size out_len
338* @param out_len number of requested bytes
339* @return 0 on success, negative on failure
340*/
341BOTAN_FFI_EXPORT(3, 0) int botan_system_rng_get(uint8_t* out, size_t out_len);
342
343/**
344* Reseed a random number generator
345* Uses the System_RNG as a seed generator.
346*
347* @param rng rng object
348* @param bits number of bits to reseed with
349* @return 0 on success, a negative value on failure
350*/
351BOTAN_FFI_EXPORT(2, 0) int botan_rng_reseed(botan_rng_t rng, size_t bits);
352
353/**
354* Reseed a random number generator
355*
356* @param rng rng object
357* @param source_rng the rng that will be read from
358* @param bits number of bits to reseed with
359* @return 0 on success, a negative value on failure
360*/
361BOTAN_FFI_EXPORT(2, 8) int botan_rng_reseed_from_rng(botan_rng_t rng, botan_rng_t source_rng, size_t bits);
362
363/**
364* Add some seed material to a random number generator
365*
366* @param rng rng object
367* @param entropy the data to add
368* @param entropy_len length of entropy buffer
369* @return 0 on success, a negative value on failure
370*/
371BOTAN_FFI_EXPORT(2, 8) int botan_rng_add_entropy(botan_rng_t rng, const uint8_t* entropy, size_t entropy_len);
372
373/**
374* Frees all resources of the random number generator object
375* @param rng rng object
376* @return 0 if success, error if invalid object handle
377*/
379
380/*
381* Opaque type of an eXtendable Output Function (XOF)
382*/
383typedef struct botan_xof_struct* botan_xof_t;
384
385/**
386* Initialize an eXtendable Output Function
387* @param xof XOF object
388* @param xof_name name of the XOF, e.g., "SHAKE-128"
389* @param flags should be 0 in current API revision, all other uses are reserved
390* and return BOTAN_FFI_ERROR_BAD_FLAG
391*/
392BOTAN_FFI_EXPORT(3, 11) int botan_xof_init(botan_xof_t* xof, const char* xof_name, uint32_t flags);
393
394/**
395* Copy the state of an eXtendable Output Function
396* @param dest destination XOF object
397* @param source source XOF object
398* @return 0 on success, a negative value on failure
399*/
401
402/**
403* Writes the block size of the eXtendable Output Function to *block_size
404* @param xof XOF object
405* @param block_size variable to hold the XOF's block size
406* @return 0 on success, a negative value on failure
407*/
408BOTAN_FFI_EXPORT(3, 11) int botan_xof_block_size(botan_xof_t xof, size_t* block_size);
409
410/**
411* Get the name of this eXtendable Output Function
412* @param xof the object to read
413* @param name output buffer
414* @param name_len on input, the length of buffer, on success the number of bytes written
415*/
416BOTAN_FFI_EXPORT(3, 11) int botan_xof_name(botan_xof_t xof, char* name, size_t* name_len);
417
418/**
419* Get the input/output state of this eXtendable Output Function
420* Typically, XOFs don't accept input as soon as the first output bytes were requested.
421* @param xof the object to read
422* @returns 1 iff the XOF is still accepting input bytes
423*/
425
426/**
427* Reinitializes the state of the eXtendable Output Function.
428* @param xof XOF object
429* @return 0 on success, a negative value on failure
430*/
432
433/**
434* Send more input to the eXtendable Output Function
435* @param xof XOF object
436* @param in input buffer
437* @param in_len number of bytes to read from the input buffer
438* @return 0 on success, a negative value on failure
439*/
440BOTAN_FFI_EXPORT(3, 11) int botan_xof_update(botan_xof_t xof, const uint8_t* in, size_t in_len);
441
442/**
443* Generate output bytes from the eXtendable Output Function
444* @param xof XOF object
445* @param out output buffer
446* @param out_len number of bytes to write into the output buffer
447* @return 0 on success, a negative value on failure
448*/
449BOTAN_FFI_EXPORT(3, 11) int botan_xof_output(botan_xof_t xof, uint8_t* out, size_t out_len);
450
451/**
452* Frees all resources of the eXtendable Output Function object
453* @param xof xof object
454* @return 0 if success, error if invalid object handle
455*/
457
458/*
459* Opaque type of a hash function
460*/
461typedef struct botan_hash_struct* botan_hash_t;
462
463/**
464* Initialize a hash function object
465* @param hash hash object
466* @param hash_name name of the hash function, e.g., "SHA-384"
467* @param flags should be 0 in current API revision, all other uses are reserved
468* and return BOTAN_FFI_ERROR_BAD_FLAG
469*/
470BOTAN_FFI_EXPORT(2, 0) int botan_hash_init(botan_hash_t* hash, const char* hash_name, uint32_t flags);
471
472/**
473* Copy the state of a hash function object
474* @param dest destination hash object
475* @param source source hash object
476* @return 0 on success, a negative value on failure
477*/
479
480/**
481* Writes the output length of the hash function to *output_length
482* @param hash hash object
483* @param output_length output buffer to hold the hash function output length
484* @return 0 on success, a negative value on failure
485*/
486BOTAN_FFI_EXPORT(2, 0) int botan_hash_output_length(botan_hash_t hash, size_t* output_length);
487
488/**
489* Writes the block size of the hash function to *block_size
490* @param hash hash object
491* @param block_size output buffer to hold the hash function output length
492* @return 0 on success, a negative value on failure
493*/
494BOTAN_FFI_EXPORT(2, 2) int botan_hash_block_size(botan_hash_t hash, size_t* block_size);
495
496/**
497* Send more input to the hash function
498* @param hash hash object
499* @param in input buffer
500* @param in_len number of bytes to read from the input buffer
501* @return 0 on success, a negative value on failure
502*/
503BOTAN_FFI_EXPORT(2, 0) int botan_hash_update(botan_hash_t hash, const uint8_t* in, size_t in_len);
504
505/**
506* Finalizes the hash computation and writes the output to
507* out[0:botan_hash_output_length()] then reinitializes for computing
508* another digest as if botan_hash_clear had been called.
509* @param hash hash object
510* @param out output buffer
511* @return 0 on success, a negative value on failure
512*/
513BOTAN_FFI_EXPORT(2, 0) int botan_hash_final(botan_hash_t hash, uint8_t out[]);
514
515/**
516* Reinitializes the state of the hash computation. A hash can
517* be computed (with update/final) immediately.
518* @param hash hash object
519* @return 0 on success, a negative value on failure
520*/
522
523/**
524* Frees all resources of the hash object
525* @param hash hash object
526* @return 0 if success, error if invalid object handle
527*/
529
530/**
531* Get the name of this hash function
532* @param hash the object to read
533* @param name output buffer
534* @param name_len on input, the length of buffer, on success the number of bytes written
535*/
536BOTAN_FFI_EXPORT(2, 8) int botan_hash_name(botan_hash_t hash, char* name, size_t* name_len);
537
538/*
539* Opaque type of a message authentication code
540*/
541typedef struct botan_mac_struct* botan_mac_t;
542
543/**
544* Initialize a message authentication code object
545* @param mac mac object
546* @param mac_name name of the hash function, e.g., "HMAC(SHA-384)"
547* @param flags should be 0 in current API revision, all other uses are reserved
548* and return a negative value (error code)
549* @return 0 on success, a negative value on failure
550*/
551BOTAN_FFI_EXPORT(2, 0) int botan_mac_init(botan_mac_t* mac, const char* mac_name, uint32_t flags);
552
553/**
554* Writes the output length of the message authentication code to *output_length
555* @param mac mac object
556* @param output_length output buffer to hold the MAC output length
557* @return 0 on success, a negative value on failure
558*/
559BOTAN_FFI_EXPORT(2, 0) int botan_mac_output_length(botan_mac_t mac, size_t* output_length);
560
561/**
562* Sets the key on the MAC
563* @param mac mac object
564* @param key buffer holding the key
565* @param key_len size of the key buffer in bytes
566* @return 0 on success, a negative value on failure
567*/
568BOTAN_FFI_EXPORT(2, 0) int botan_mac_set_key(botan_mac_t mac, const uint8_t* key, size_t key_len);
569
570/**
571* Sets the nonce on the MAC
572* @param mac mac object
573* @param nonce buffer holding the key
574* @param nonce_len size of the key buffer in bytes
575* @return 0 on success, a negative value on failure
576*/
577BOTAN_FFI_EXPORT(3, 0) int botan_mac_set_nonce(botan_mac_t mac, const uint8_t* nonce, size_t nonce_len);
578
579/**
580* Send more input to the message authentication code
581* @param mac mac object
582* @param buf input buffer
583* @param len number of bytes to read from the input buffer
584* @return 0 on success, a negative value on failure
585*/
586BOTAN_FFI_EXPORT(2, 0) int botan_mac_update(botan_mac_t mac, const uint8_t* buf, size_t len);
587
588/**
589* Finalizes the MAC computation and writes the output to
590* out[0:botan_mac_output_length()] then reinitializes for computing
591* another MAC as if botan_mac_clear had been called.
592* @param mac mac object
593* @param out output buffer
594* @return 0 on success, a negative value on failure
595*/
596BOTAN_FFI_EXPORT(2, 0) int botan_mac_final(botan_mac_t mac, uint8_t out[]);
597
598/**
599* Reinitializes the state of the MAC computation. A MAC can
600* be computed (with update/final) immediately.
601* @param mac mac object
602* @return 0 on success, a negative value on failure
603*/
605
606/**
607* Get the name of this MAC
608* @param mac the object to read
609* @param name output buffer
610* @param name_len on input, the length of buffer, on success the number of bytes written
611*/
612BOTAN_FFI_EXPORT(2, 8) int botan_mac_name(botan_mac_t mac, char* name, size_t* name_len);
613
614/**
615* Get the key length limits of this auth code
616* @param mac the object to read
617* @param out_minimum_keylength if non-NULL, will be set to minimum keylength of MAC
618* @param out_maximum_keylength if non-NULL, will be set to maximum keylength of MAC
619* @param out_keylength_modulo if non-NULL will be set to byte multiple of valid keys
620*/
623 size_t* out_minimum_keylength,
624 size_t* out_maximum_keylength,
625 size_t* out_keylength_modulo);
626
627/**
628* Frees all resources of the MAC object
629* @param mac mac object
630* @return 0 if success, error if invalid object handle
631*/
633
634/*
635* Opaque type of a cipher mode
636*/
637typedef struct botan_cipher_struct* botan_cipher_t;
638
639#define BOTAN_CIPHER_INIT_FLAG_MASK_DIRECTION 1
640#define BOTAN_CIPHER_INIT_FLAG_ENCRYPT 0
641#define BOTAN_CIPHER_INIT_FLAG_DECRYPT 1
642
643/**
644* Initialize a cipher object
645*/
646BOTAN_FFI_EXPORT(2, 0) int botan_cipher_init(botan_cipher_t* cipher, const char* name, uint32_t flags);
647
648/**
649* Return the name of the cipher object
650*/
651BOTAN_FFI_EXPORT(2, 8) int botan_cipher_name(botan_cipher_t cipher, char* name, size_t* name_len);
652
653/**
654* Return the output length of this cipher, for a particular input length.
655*/
656BOTAN_FFI_EXPORT(2, 8) int botan_cipher_output_length(botan_cipher_t cipher, size_t in_len, size_t* out_len);
657
658/**
659* Return if the specified nonce length is valid for this cipher
660*/
662
663/**
664* Get the tag length of the cipher (0 for non-AEAD modes)
665*/
666BOTAN_FFI_EXPORT(2, 0) int botan_cipher_get_tag_length(botan_cipher_t cipher, size_t* tag_size);
667
668/**
669* Returns 1 iff the cipher provides authentication as well as confidentiality.
670*/
672
673/**
674 * Returns 1 iff the cipher requires the entire message before any
675 * encryption or decryption can be performed. No output data will be produced
676 * in botan_cipher_update() until the final flag is set.
677 */
679
680/**
681* Get the default nonce length of this cipher
682*/
684
685/**
686* Return the update granularity of the cipher; botan_cipher_update must be
687* called with blocks of this size, except for the final.
688*/
690
691/**
692* Return the ideal update granularity of the cipher. This is some multiple of the
693* update granularity, reflecting possibilities for optimization.
694*/
696
697/**
698* Get information about the key lengths. Prefer botan_cipher_get_keyspec
699*/
701int botan_cipher_query_keylen(botan_cipher_t cipher, size_t* out_minimum_keylength, size_t* out_maximum_keylength);
702
703/**
704* Get information about the supported key lengths.
705*/
707int botan_cipher_get_keyspec(botan_cipher_t cipher, size_t* min_keylen, size_t* max_keylen, size_t* mod_keylen);
708
709/**
710* Set the key for this cipher object
711*/
712BOTAN_FFI_EXPORT(2, 0) int botan_cipher_set_key(botan_cipher_t cipher, const uint8_t* key, size_t key_len);
713
714/**
715* Reset the message specific state for this cipher.
716* Without resetting the keys, this resets the nonce, and any state
717* associated with any message bits that have been processed so far.
718*
719* It is conceptually equivalent to calling botan_cipher_clear followed
720* by botan_cipher_set_key with the original key.
721*/
723
724/**
725* Set the associated data. Will fail if cipher is not an AEAD
726*/
727BOTAN_FFI_EXPORT(2, 0) int botan_cipher_set_associated_data(botan_cipher_t cipher, const uint8_t* ad, size_t ad_len);
728
729/**
730* Begin processing a new message using the provided nonce
731*/
732BOTAN_FFI_EXPORT(2, 0) int botan_cipher_start(botan_cipher_t cipher, const uint8_t* nonce, size_t nonce_len);
733
734#define BOTAN_CIPHER_UPDATE_FLAG_FINAL (1U << 0)
735
736/**
737* @brief Encrypt/Decrypt some data and/or finalize the encryption/decryption
738*
739* This encrypts as many bytes from @p input_bytes into @p output_bytes as
740* possible. Unless ``BOTAN_CIPHER_UPDATE_FLAG_FINAL`` is set, this function will
741* consume bytes in multiples of botan_cipher_get_update_granularity().
742* @p input_consumed and @p output_written will be set accordingly and it is the
743* caller's responsibility to adapt their buffers accordingly before calling this
744* function again. Note that, unless ``BOTAN_CIPHER_UPDATE_FLAG_FINAL`` is set,
745* the cipher will at most generate @p input_size output bytes.
746*
747* Eventually, the caller must set the ``BOTAN_CIPHER_UPDATE_FLAG_FINAL`` flag to
748* indicate that no more input will be provided. This will cause the cipher to
749* consume all given input bytes and produce the final output; or return a
750* ``BOTAN_FFI_ERROR_INSUFFICIENT_BUFFER_SPACE`` error if the given output buffer
751* was too small. In the latter case, @p output_written will be set to the
752* required buffer size. Calling again with ``BOTAN_CIPHER_UPDATE_FLAG_FINAL``, a
753* big enough buffer and no further input will then produce the final output.
754*
755* Note that some ciphers require the entire message to be provided before any
756* output is produced. @sa botan_cipher_requires_entire_message().
757*/
760 uint32_t flags,
761 uint8_t output[],
762 size_t output_size,
763 size_t* output_written,
764 const uint8_t input_bytes[],
765 size_t input_size,
766 size_t* input_consumed);
767
768/**
769* Reset the key, nonce, AD and all other state on this cipher object
770*/
772
773/**
774* Destroy the cipher object
775* @return 0 if success, error if invalid object handle
776*/
778
779/*
780* Derive a key from a passphrase for a number of iterations
781* @param pbkdf_algo PBKDF algorithm, e.g., "PBKDF2(SHA-256)"
782* @param out buffer to store the derived key, must be of out_len bytes
783* @param out_len the desired length of the key to produce
784* @param passphrase the password to derive the key from
785* @param salt a randomly chosen salt
786* @param salt_len length of salt in bytes
787* @param iterations the number of iterations to use (use 10K or more)
788* @return 0 on success, a negative value on failure
789*
790* Deprecated: use
791* botan_pwdhash(pbkdf_algo, iterations, 0, 0, out, out_len,
792* passphrase, 0, salt, salt_len);
793*/
794BOTAN_FFI_DEPRECATED("Use botan_pwdhash")
796int botan_pbkdf(const char* pbkdf_algo,
797 uint8_t out[],
798 size_t out_len,
799 const char* passphrase,
800 const uint8_t salt[],
801 size_t salt_len,
802 size_t iterations);
803
804/**
805* Derive a key from a passphrase, running until msec time has elapsed.
806* @param pbkdf_algo PBKDF algorithm, e.g., "PBKDF2(SHA-256)"
807* @param out buffer to store the derived key, must be of out_len bytes
808* @param out_len the desired length of the key to produce
809* @param passphrase the password to derive the key from
810* @param salt a randomly chosen salt
811* @param salt_len length of salt in bytes
812* @param milliseconds_to_run if iterations is zero, then instead the PBKDF is
813* run until milliseconds_to_run milliseconds has passed
814* @param out_iterations_used set to the number iterations executed
815* @return 0 on success, a negative value on failure
816*
817* Deprecated: use
818*
819* botan_pwdhash_timed(pbkdf_algo,
820* static_cast<uint32_t>(ms_to_run),
821* iterations_used,
822* nullptr,
823* nullptr,
824* out, out_len,
825* password, 0,
826* salt, salt_len);
827*/
829int botan_pbkdf_timed(const char* pbkdf_algo,
830 uint8_t out[],
831 size_t out_len,
832 const char* passphrase,
833 const uint8_t salt[],
834 size_t salt_len,
835 size_t milliseconds_to_run,
836 size_t* out_iterations_used);
837
838/*
839* Derive a key from a passphrase
840* @param algo PBKDF algorithm, e.g., "PBKDF2(SHA-256)" or "Scrypt"
841* @param param1 the first PBKDF algorithm parameter
842* @param param2 the second PBKDF algorithm parameter (may be zero if unneeded)
843* @param param3 the third PBKDF algorithm parameter (may be zero if unneeded)
844* @param out buffer to store the derived key, must be of out_len bytes
845* @param out_len the desired length of the key to produce
846* @param passphrase the password to derive the key from
847* @param passphrase_len if > 0, specifies length of password. If len == 0, then
848* strlen will be called on passphrase to compute the length.
849* @param salt a randomly chosen salt
850* @param salt_len length of salt in bytes
851* @return 0 on success, a negative value on failure
852*/
854int botan_pwdhash(const char* algo,
855 size_t param1,
856 size_t param2,
857 size_t param3,
858 uint8_t out[],
859 size_t out_len,
860 const char* passphrase,
861 size_t passphrase_len,
862 const uint8_t salt[],
863 size_t salt_len);
864
865/*
866* Derive a key from a passphrase
867* @param pbkdf_algo PBKDF algorithm, e.g., "Scrypt" or "PBKDF2(SHA-256)"
868* @param msec the desired runtime in milliseconds
869* @param param1 will be set to the first password hash parameter
870* @param param2 will be set to the second password hash parameter
871* @param param3 will be set to the third password hash parameter
872* @param out buffer to store the derived key, must be of out_len bytes
873* @param out_len the desired length of the key to produce
874* @param passphrase the password to derive the key from
875* @param passphrase_len if > 0, specifies length of password. If len == 0, then
876* strlen will be called on passphrase to compute the length.
877* @param salt a randomly chosen salt
878* @param salt_len length of salt in bytes
879* @return 0 on success, a negative value on failure
880*/
882int botan_pwdhash_timed(const char* algo,
883 uint32_t msec,
884 size_t* param1,
885 size_t* param2,
886 size_t* param3,
887 uint8_t out[],
888 size_t out_len,
889 const char* passphrase,
890 size_t passphrase_len,
891 const uint8_t salt[],
892 size_t salt_len);
893
894/**
895* Derive a key using scrypt
896* Deprecated; use
897* botan_pwdhash("Scrypt", N, r, p, out, out_len, password, 0, salt, salt_len);
898*/
899BOTAN_FFI_DEPRECATED("Use botan_pwdhash")
901int botan_scrypt(uint8_t out[],
902 size_t out_len,
903 const char* passphrase,
904 const uint8_t salt[],
905 size_t salt_len,
906 size_t N,
907 size_t r,
908 size_t p);
909
910/**
911* Derive a key
912* @param kdf_algo KDF algorithm, e.g., "SP800-56C"
913* @param out buffer holding the derived key, must be of length out_len
914* @param out_len the desired output length in bytes
915* @param secret the secret input
916* @param secret_len size of secret in bytes
917* @param salt a diversifier
918* @param salt_len size of salt in bytes
919* @param label purpose for the derived keying material
920* @param label_len size of label in bytes
921* @return 0 on success, a negative value on failure
922*/
924int botan_kdf(const char* kdf_algo,
925 uint8_t out[],
926 size_t out_len,
927 const uint8_t secret[],
928 size_t secret_len,
929 const uint8_t salt[],
930 size_t salt_len,
931 const uint8_t label[],
932 size_t label_len);
933
934/*
935* Raw Block Cipher (PRP) interface
936*/
937typedef struct botan_block_cipher_struct* botan_block_cipher_t;
938
939/**
940* Initialize a block cipher object
941*/
942BOTAN_FFI_EXPORT(2, 1) int botan_block_cipher_init(botan_block_cipher_t* bc, const char* cipher_name);
943
944/**
945* Destroy a block cipher object
946* @return 0 if success, error if invalid object handle
947*/
949
950/**
951* Reinitializes the block cipher
952* @return 0 on success, a negative value on failure
953*/
955
956/**
957* Set the key for a block cipher instance
958*/
959BOTAN_FFI_EXPORT(2, 1) int botan_block_cipher_set_key(botan_block_cipher_t bc, const uint8_t key[], size_t len);
960
961/**
962* Return the positive block size of this block cipher, or negative to
963* indicate an error
964*/
966
967/**
968* Encrypt one or more blocks with the cipher
969*/
971int botan_block_cipher_encrypt_blocks(botan_block_cipher_t bc, const uint8_t in[], uint8_t out[], size_t blocks);
972
973/**
974* Decrypt one or more blocks with the cipher
975*/
977int botan_block_cipher_decrypt_blocks(botan_block_cipher_t bc, const uint8_t in[], uint8_t out[], size_t blocks);
978
979/**
980* Get the name of this block cipher
981* @param cipher the object to read
982* @param name output buffer
983* @param name_len on input, the length of buffer, on success the number of bytes written
984*/
985BOTAN_FFI_EXPORT(2, 8) int botan_block_cipher_name(botan_block_cipher_t cipher, char* name, size_t* name_len);
986
987/**
988* Get the key length limits of this block cipher
989* @param cipher the object to read
990* @param out_minimum_keylength if non-NULL, will be set to minimum keylength of cipher
991* @param out_maximum_keylength if non-NULL, will be set to maximum keylength of cipher
992* @param out_keylength_modulo if non-NULL will be set to byte multiple of valid keys
993*/
996 size_t* out_minimum_keylength,
997 size_t* out_maximum_keylength,
998 size_t* out_keylength_modulo);
999
1000/*
1001* Multiple precision integers (MPI)
1002*/
1003typedef struct botan_mp_struct* botan_mp_t;
1004
1005/**
1006* Initialize an MPI
1007*/
1009
1010/**
1011* Destroy (deallocate) an MPI
1012* @return 0 if success, error if invalid object handle
1013*/
1015
1016/**
1017* Convert the MPI to a hex string. Writes up to botan_mp_num_bytes(mp)*2 + 5 bytes
1018*
1019* Prefer botan_mp_view_hex
1020*/
1021BOTAN_FFI_EXPORT(2, 1) int botan_mp_to_hex(botan_mp_t mp, char* out);
1022
1023/**
1024* View the hex string encoding of the MPI.
1025*/
1027
1028/**
1029* Convert the MPI to a string. Currently radix == 10 and radix == 16 are supported.
1030*/
1031BOTAN_FFI_EXPORT(2, 1) int botan_mp_to_str(botan_mp_t mp, uint8_t radix, char* out, size_t* out_len);
1032
1033/**
1034* View the MPI as a radix-N integer. Currently only radix 10 and radix 16 are supported
1035*/
1036BOTAN_FFI_EXPORT(3, 10) int botan_mp_view_str(botan_mp_t mp, uint8_t radix, botan_view_ctx ctx, botan_view_str_fn view);
1037
1038/**
1039* Set the MPI to zero
1040*/
1042
1043/**
1044* Set the MPI value from an int
1045*/
1046BOTAN_FFI_EXPORT(2, 1) int botan_mp_set_from_int(botan_mp_t mp, int initial_value);
1047
1048/**
1049* Set the MPI value from another MP object
1050*/
1052
1053/**
1054* Set the MPI value from a string
1055*/
1056BOTAN_FFI_EXPORT(2, 1) int botan_mp_set_from_str(botan_mp_t dest, const char* str);
1057
1058/**
1059* Set the MPI value from a string with arbitrary radix.
1060* For arbitrary being 10 or 16.
1061*/
1062BOTAN_FFI_EXPORT(2, 1) int botan_mp_set_from_radix_str(botan_mp_t dest, const char* str, size_t radix);
1063
1064/**
1065* Return the number of significant bits in the MPI
1066*/
1067BOTAN_FFI_EXPORT(2, 1) int botan_mp_num_bits(botan_mp_t n, size_t* bits);
1068
1069/**
1070* Return the number of significant bytes in the MPI
1071*/
1072BOTAN_FFI_EXPORT(2, 1) int botan_mp_num_bytes(botan_mp_t n, size_t* bytes);
1073
1074/*
1075* Convert the MPI to a big-endian binary string. Writes botan_mp_num_bytes to vec
1076*
1077* Note that the sign of the integer is ignored here; only the absolute value is copied
1078*/
1079BOTAN_FFI_EXPORT(2, 1) int botan_mp_to_bin(botan_mp_t mp, uint8_t vec[]);
1080
1081/*
1082* View the big-endian binary string encoding of this integer
1083*
1084* Note that the sign of the integer is ignored here; only the absolute value is viewed
1085*/
1087
1088/*
1089* Set an MP to the big-endian binary value
1090*/
1091BOTAN_FFI_EXPORT(2, 1) int botan_mp_from_bin(botan_mp_t mp, const uint8_t vec[], size_t vec_len);
1092
1093/*
1094* Convert the MPI to a uint32_t, if possible. Fails if MPI is negative or too large.
1095*/
1096BOTAN_FFI_EXPORT(2, 1) int botan_mp_to_uint32(botan_mp_t mp, uint32_t* val);
1097
1098/**
1099* This function should have been named mp_is_non_negative. Returns 1
1100* iff mp is greater than *or equal to* zero. Use botan_mp_is_negative
1101* to detect negative numbers, botan_mp_is_zero to check for zero.
1102*/
1104
1105/**
1106* Return 1 iff mp is less than 0
1107*/
1109
1111
1113
1114BOTAN_FFI_DEPRECATED("Use botan_mp_get_bit(0)") BOTAN_FFI_EXPORT(2, 1) int botan_mp_is_odd(botan_mp_t mp);
1115BOTAN_FFI_DEPRECATED("Use botan_mp_get_bit(0)") BOTAN_FFI_EXPORT(2, 1) int botan_mp_is_even(botan_mp_t mp);
1116
1117BOTAN_FFI_EXPORT(2, 8) int botan_mp_add_u32(botan_mp_t result, botan_mp_t x, uint32_t y);
1118BOTAN_FFI_EXPORT(2, 8) int botan_mp_sub_u32(botan_mp_t result, botan_mp_t x, uint32_t y);
1119
1123
1124BOTAN_FFI_EXPORT(2, 1)
1125int botan_mp_div(botan_mp_t quotient, botan_mp_t remainder, botan_mp_t x, botan_mp_t y);
1126
1127BOTAN_FFI_EXPORT(2, 1)
1129
1130/*
1131* Returns 0 if x != y
1132* Returns 1 if x == y
1133* Returns negative number on error
1134*/
1136
1137/*
1138* Sets *result to comparison result:
1139* -1 if x < y, 0 if x == y, 1 if x > y
1140* Returns negative number on error or zero on success
1141*/
1142BOTAN_FFI_EXPORT(2, 1) int botan_mp_cmp(int* result, botan_mp_t x, botan_mp_t y);
1143
1144/*
1145* Swap two botan_mp_t
1146*/
1148
1149/* Return (base^exponent) % modulus */
1150BOTAN_FFI_EXPORT(2, 1)
1151int botan_mp_powmod(botan_mp_t out, botan_mp_t base, botan_mp_t exponent, botan_mp_t modulus);
1152
1153BOTAN_FFI_EXPORT(2, 1) int botan_mp_lshift(botan_mp_t out, botan_mp_t in, size_t shift);
1154BOTAN_FFI_EXPORT(2, 1) int botan_mp_rshift(botan_mp_t out, botan_mp_t in, size_t shift);
1155
1157
1158BOTAN_FFI_EXPORT(2, 1) int botan_mp_rand_bits(botan_mp_t rand_out, botan_rng_t rng, size_t bits);
1159
1160BOTAN_FFI_EXPORT(2, 1)
1161int botan_mp_rand_range(botan_mp_t rand_out, botan_rng_t rng, botan_mp_t lower_bound, botan_mp_t upper_bound);
1162
1164
1165/**
1166* Returns 0 if n is not prime
1167* Returns 1 if n is prime
1168* Returns negative number on error
1169*/
1170BOTAN_FFI_EXPORT(2, 1) int botan_mp_is_prime(botan_mp_t n, botan_rng_t rng, size_t test_prob);
1171
1172/**
1173* Returns 0 if specified bit of n is not set
1174* Returns 1 if specified bit of n is set
1175* Returns negative number on error
1176*/
1177BOTAN_FFI_EXPORT(2, 1) int botan_mp_get_bit(botan_mp_t n, size_t bit);
1178
1179/**
1180* Set the specified bit
1181*/
1182BOTAN_FFI_EXPORT(2, 1) int botan_mp_set_bit(botan_mp_t n, size_t bit);
1183
1184/**
1185* Clear the specified bit
1186*/
1187BOTAN_FFI_EXPORT(2, 1) int botan_mp_clear_bit(botan_mp_t n, size_t bit);
1188
1189/* Bcrypt password hashing */
1190
1191/**
1192* Create a password hash using Bcrypt
1193* @param out buffer holding the password hash, should be of length 64 bytes
1194* @param out_len the desired output length in bytes
1195* @param password the password
1196* @param rng a random number generator
1197* @param work_factor how much work to do to slow down guessing attacks
1198* @param flags should be 0 in current API revision, all other uses are reserved
1199* and return BOTAN_FFI_ERROR_BAD_FLAG
1200* @return 0 on success, a negative value on failure
1201*
1202* Output is formatted bcrypt $2a$...
1203*
1204* TOD(Botan4) this should use char for the type of `out`
1205*/
1206BOTAN_FFI_EXPORT(2, 0)
1208 uint8_t* out, size_t* out_len, const char* password, botan_rng_t rng, size_t work_factor, uint32_t flags);
1209
1210/**
1211* Check a previously created password hash
1212* @param pass the password to check against
1213* @param hash the stored hash to check against
1214* @return 0 if if this password/hash combination is valid,
1215* 1 if the combination is not valid (but otherwise well formed),
1216* negative on error
1217*/
1218BOTAN_FFI_EXPORT(2, 0) int botan_bcrypt_is_valid(const char* pass, const char* hash);
1219
1220/*
1221* OIDs
1222*/
1223
1224typedef struct botan_asn1_oid_struct* botan_asn1_oid_t;
1225
1226/**
1227* @returns negative number on error, or zero on success
1228*/
1230
1231/**
1232* Create an OID from a string, either dot notation (e.g. '1.2.3.4') or a registered name (e.g. 'RSA')
1233* @param oid handle to the resulting OID
1234* @param oid_str the name of the OID to create
1235* @returns negative number on error, or zero on success
1236*/
1237BOTAN_FFI_EXPORT(3, 8) int botan_oid_from_string(botan_asn1_oid_t* oid, const char* oid_str);
1238
1239/**
1240* Registers an OID so that it may later be retrieved by name
1241* @returns negative number on error, or zero on success
1242*/
1243BOTAN_FFI_EXPORT(3, 8) int botan_oid_register(botan_asn1_oid_t oid, const char* name);
1244
1245/**
1246* View an OID in dot notation
1247*/
1249
1250/**
1251* View an OIDs registered name if it exists, else its dot notation
1252*/
1254
1255/**
1256* @returns 0 if a != b
1257* @returns 1 if a == b
1258* @returns negative number on error
1259*/
1261
1262/**
1263* Sets @param result to comparison result:
1264* -1 if a < b, 0 if a == b, 1 if a > b
1265* @returns negative number on error or zero on success
1266*/
1268
1269/*
1270* EC Groups
1271*/
1272
1273typedef struct botan_ec_group_struct* botan_ec_group_t;
1274
1275/**
1276* @returns negative number on error, or zero on success
1277*/
1279
1280/**
1281* Checks if in this build configuration it is possible to register an application specific elliptic curve and sets
1282* @param out to 1 if so, 0 otherwise
1283* @returns 0 on success, a negative value on failure
1284*/
1286
1287/**
1288* Checks if in this build configuration botan_ec_group_from_name(group_ptr, name) will succeed and sets
1289* @param out to 1 if so, 0 otherwise.
1290* @returns negative number on error, or zero on success
1291*/
1292BOTAN_FFI_EXPORT(3, 8) int botan_ec_group_supports_named_group(const char* name, int* out);
1293
1294/**
1295* Create a new EC Group from parameters
1296* @warning use only elliptic curve parameters that you trust
1297*
1298* @param ec_group the new object will be placed here
1299* @param p the elliptic curve prime (at most 521 bits)
1300* @param a the elliptic curve a param
1301* @param b the elliptic curve b param
1302* @param base_x the x coordinate of the group generator
1303* @param base_y the y coordinate of the group generator
1304* @param order the order of the group
1305* @returns negative number on error, or zero on success
1306*/
1307BOTAN_FFI_EXPORT(3, 8)
1309 botan_asn1_oid_t oid,
1310 botan_mp_t p,
1311 botan_mp_t a,
1312 botan_mp_t b,
1313 botan_mp_t base_x,
1314 botan_mp_t base_y,
1315 botan_mp_t order);
1316
1317/**
1318* Decode a BER encoded ECC domain parameter set
1319* @param ec_group the new object will be placed here
1320* @param ber encoding
1321* @param ber_len size of the encoding in bytes
1322* @returns negative number on error, or zero on success
1323*/
1324BOTAN_FFI_EXPORT(3, 8) int botan_ec_group_from_ber(botan_ec_group_t* ec_group, const uint8_t* ber, size_t ber_len);
1325
1326/**
1327* Initialize an EC Group from the PEM/ASN.1 encoding
1328* @param ec_group the new object will be placed here
1329* @param pem encoding
1330* @returns negative number on error, or zero on success
1331*/
1332BOTAN_FFI_EXPORT(3, 8) int botan_ec_group_from_pem(botan_ec_group_t* ec_group, const char* pem);
1333
1334/**
1335* Initialize an EC Group from a group named by an object identifier
1336* @param ec_group the new object will be placed here
1337* @param oid a known OID
1338* @returns negative number on error, or zero on success
1339*/
1341
1342/**
1343* Initialize an EC Group from a common group name (eg "secp256r1")
1344* @param ec_group the new object will be placed here
1345* @param name a known group name
1346* @returns negative number on error, or zero on success
1347*/
1348BOTAN_FFI_EXPORT(3, 8) int botan_ec_group_from_name(botan_ec_group_t* ec_group, const char* name);
1349
1350/**
1351* Unregister a previously registered group.
1352* @param oid the oid associated with the group to unregister
1353* @returns 1 if the group was found and unregistered, else 0
1354*
1355* Using this is discouraged for normal use. This is only useful or necessary if
1356* you are registering a very large number of distinct groups, and need to worry about memory constraints.
1357*/
1359
1360/**
1361* View an EC Group in DER encoding
1362*/
1363BOTAN_FFI_EXPORT(3, 8)
1365
1366/**
1367* View an EC Group in PEM encoding
1368*/
1369BOTAN_FFI_EXPORT(3, 8)
1371
1372/**
1373* Get the curve OID of an EC Group
1374*/
1376
1377/**
1378* Get the prime modulus of the field
1379*/
1381
1382/**
1383* Get the a parameter of the elliptic curve equation
1384*/
1386
1387/**
1388* Get the b parameter of the elliptic curve equation
1389*/
1391
1392/**
1393* Get the x coordinate of the base point
1394*/
1396
1397/**
1398* Get the y coordinate of the base point
1399*/
1401
1402/**
1403* Get the order of the base point
1404*/
1406
1407/**
1408* @returns 0 if curve1 != curve2
1409* @returns 1 if curve1 == curve2
1410* @returns negative number on error
1411*/
1413
1414/*
1415* Public/private key creation, import, ...
1416*/
1417typedef struct botan_privkey_struct* botan_privkey_t;
1418
1419/**
1420* Create a new private key
1421* @param key the new object will be placed here
1422* @param algo_name something like "RSA" or "ECDSA"
1423* @param algo_params is specific to the algorithm. For RSA, specifies
1424* the modulus bit length. For ECC is the name of the curve.
1425* @param rng a random number generator
1426*/
1427BOTAN_FFI_EXPORT(2, 0)
1428int botan_privkey_create(botan_privkey_t* key, const char* algo_name, const char* algo_params, botan_rng_t rng);
1429
1430/**
1431* Create a new ec private key
1432* @param key the new object will be placed here
1433* @param algo_name something like "ECDSA" or "ECDH"
1434* @param ec_group a (possibly application specific) elliptic curve
1435* @param rng a random number generator
1436*/
1437BOTAN_FFI_EXPORT(3, 8)
1438int botan_ec_privkey_create(botan_privkey_t* key, const char* algo_name, botan_ec_group_t ec_group, botan_rng_t rng);
1439
1440#define BOTAN_CHECK_KEY_EXPENSIVE_TESTS 1
1441
1442BOTAN_FFI_EXPORT(2, 0) int botan_privkey_check_key(botan_privkey_t key, botan_rng_t rng, uint32_t flags);
1443
1444BOTAN_FFI_DEPRECATED("Use botan_privkey_create")
1445BOTAN_FFI_EXPORT(2, 0) int botan_privkey_create_rsa(botan_privkey_t* key, botan_rng_t rng, size_t n_bits);
1446BOTAN_FFI_DEPRECATED("Use botan_privkey_create")
1447BOTAN_FFI_EXPORT(2, 0) int botan_privkey_create_ecdsa(botan_privkey_t* key, botan_rng_t rng, const char* params);
1448BOTAN_FFI_DEPRECATED("Use botan_privkey_create")
1449BOTAN_FFI_EXPORT(2, 0) int botan_privkey_create_ecdh(botan_privkey_t* key, botan_rng_t rng, const char* params);
1450BOTAN_FFI_DEPRECATED("Use botan_privkey_create")
1451BOTAN_FFI_EXPORT(2, 0) int botan_privkey_create_mceliece(botan_privkey_t* key, botan_rng_t rng, size_t n, size_t t);
1452BOTAN_FFI_DEPRECATED("Use botan_privkey_create")
1453BOTAN_FFI_EXPORT(2, 0) int botan_privkey_create_dh(botan_privkey_t* key, botan_rng_t rng, const char* param);
1454
1455/**
1456 * Generates DSA key pair. Gives to a caller control over key length
1457 * and order of a subgroup 'q'.
1458 *
1459 * @param key handler to the resulting key
1460 * @param rng initialized PRNG
1461 * @param pbits length of the key in bits. Must be between in range (1024, 3072)
1462 * and multiple of 64. Bit size of the prime 'p'
1463 * @param qbits order of the subgroup. Must be in range (160, 256) and multiple
1464 * of 8
1465 *
1466 * @returns BOTAN_FFI_SUCCESS Success, `key' initialized with DSA key
1467 * @returns BOTAN_FFI_ERROR_NULL_POINTER either `key' or `rng' is NULL
1468 * @returns BOTAN_FFI_ERROR_BAD_PARAMETER unexpected value for either `pbits' or
1469 * `qbits'
1470 * @returns BOTAN_FFI_ERROR_NOT_IMPLEMENTED functionality not implemented
1471 *
1472*/
1473BOTAN_FFI_EXPORT(2, 5) int botan_privkey_create_dsa(botan_privkey_t* key, botan_rng_t rng, size_t pbits, size_t qbits);
1474
1475/**
1476 * Generates ElGamal key pair. Caller has a control over key length
1477 * and order of a subgroup 'q'. Function is able to use two types of
1478 * primes:
1479 * * if pbits-1 == qbits then safe primes are used for key generation
1480 * * otherwise generation uses group of prime order
1481 *
1482 * @param key handler to the resulting key
1483 * @param rng initialized PRNG
1484 * @param pbits length of the key in bits. Must be at least 1024
1485 * @param qbits order of the subgroup. Must be at least 160
1486 *
1487 * @returns BOTAN_FFI_SUCCESS Success, `key' initialized with DSA key
1488 * @returns BOTAN_FFI_ERROR_NULL_POINTER either `key' or `rng' is NULL
1489 * @returns BOTAN_FFI_ERROR_BAD_PARAMETER unexpected value for either `pbits' or
1490 * `qbits'
1491 * @returns BOTAN_FFI_ERROR_NOT_IMPLEMENTED functionality not implemented
1492 *
1493*/
1494BOTAN_FFI_EXPORT(2, 5)
1495int botan_privkey_create_elgamal(botan_privkey_t* key, botan_rng_t rng, size_t pbits, size_t qbits);
1496
1497/**
1498* Input currently assumed to be PKCS #8 structure;
1499* Set password to NULL to indicate no encryption expected
1500* Starting in 2.8.0, the rng parameter is unused and may be set to null
1501*/
1502BOTAN_FFI_EXPORT(2, 0)
1503int botan_privkey_load(botan_privkey_t* key, botan_rng_t rng, const uint8_t bits[], size_t len, const char* password);
1504
1505/**
1506* @return 0 if success, error if invalid object handle
1507*/
1509
1510#define BOTAN_PRIVKEY_EXPORT_FLAG_DER 0
1511#define BOTAN_PRIVKEY_EXPORT_FLAG_PEM 1
1512#define BOTAN_PRIVKEY_EXPORT_FLAG_RAW 2
1513
1514/**
1515* On input *out_len is number of bytes in out[]
1516* On output *out_len is number of bytes written (or required)
1517* If out is not big enough no output is written, *out_len is set and 1 is returned
1518* Returns 0 on success and sets
1519* If some other error occurs a negative integer is returned.
1520*/
1521BOTAN_FFI_DEPRECATED("Use botan_privkey_view_{der,pem,raw}")
1522BOTAN_FFI_EXPORT(2, 0) int botan_privkey_export(botan_privkey_t key, uint8_t out[], size_t* out_len, uint32_t flags);
1523
1524/**
1525* View the private key's DER encoding
1526*/
1528
1529/**
1530* View the private key's PEM encoding
1531*/
1533
1534/**
1535* View the private key's raw encoding
1536*/
1538
1539BOTAN_FFI_EXPORT(2, 8) int botan_privkey_algo_name(botan_privkey_t key, char out[], size_t* out_len);
1540
1541/**
1542* Set encryption_algo to NULL or "" to have the library choose a default (recommended)
1543*/
1544BOTAN_FFI_DEPRECATED("Use botan_privkey_export_encrypted_pbkdf_{msec,iter}")
1545BOTAN_FFI_EXPORT(2, 0)
1547 uint8_t out[],
1548 size_t* out_len,
1549 botan_rng_t rng,
1550 const char* passphrase,
1551 const char* encryption_algo,
1552 uint32_t flags);
1553
1554/*
1555* Export a private key, running PBKDF for specified amount of time
1556* @param key the private key to export
1557*
1558* Note: starting in 3.0, the output iterations count is not provided
1559*/
1560BOTAN_FFI_DEPRECATED("Use botan_privkey_view_encrypted_{der,pem}_timed")
1561BOTAN_FFI_EXPORT(2, 0)
1563 uint8_t out[],
1564 size_t* out_len,
1565 botan_rng_t rng,
1566 const char* passphrase,
1567 uint32_t pbkdf_msec_runtime,
1568 size_t* pbkdf_iterations_out,
1569 const char* cipher_algo,
1570 const char* pbkdf_algo,
1571 uint32_t flags);
1572
1573/**
1574* Export a private key using the specified number of iterations.
1575*/
1576BOTAN_FFI_DEPRECATED("Use botan_privkey_view_encrypted_{der,pem}")
1577BOTAN_FFI_EXPORT(2, 0)
1579 uint8_t out[],
1580 size_t* out_len,
1581 botan_rng_t rng,
1582 const char* passphrase,
1583 size_t pbkdf_iterations,
1584 const char* cipher_algo,
1585 const char* pbkdf_algo,
1586 uint32_t flags);
1587
1588/**
1589* View the encryption of a private key (binary DER encoding)
1590*
1591* Set cipher_algo, pbkdf_algo to NULL to use defaults
1592* Set pbkdf_iterations to 0 to use defaults
1593*/
1594BOTAN_FFI_EXPORT(3, 0)
1596 botan_rng_t rng,
1597 const char* passphrase,
1598 const char* cipher_algo,
1599 const char* pbkdf_algo,
1600 size_t pbkdf_iterations,
1601 botan_view_ctx ctx,
1602 botan_view_bin_fn view);
1603
1604/**
1605* View the encryption of a private key (binary DER encoding)
1606*
1607* Set cipher_algo, pbkdf_algo to NULL to use defaults
1608*/
1609BOTAN_FFI_EXPORT(3, 0)
1611 botan_rng_t rng,
1612 const char* passphrase,
1613 const char* cipher_algo,
1614 const char* pbkdf_algo,
1615 size_t pbkdf_runtime_msec,
1616 botan_view_ctx ctx,
1617 botan_view_bin_fn view);
1618
1619/**
1620* View the encryption of a private key (PEM encoding)
1621*
1622* Set cipher_algo, pbkdf_algo to NULL to use defaults
1623* Set pbkdf_iterations to 0 to use defaults
1624*/
1625BOTAN_FFI_EXPORT(3, 0)
1627 botan_rng_t rng,
1628 const char* passphrase,
1629 const char* cipher_algo,
1630 const char* pbkdf_algo,
1631 size_t pbkdf_iterations,
1632 botan_view_ctx ctx,
1633 botan_view_str_fn view);
1634
1635/**
1636* View the encryption of a private key (PEM encoding)
1637*
1638* Set cipher_algo, pbkdf_algo to NULL to use defaults
1639*/
1640BOTAN_FFI_EXPORT(3, 0)
1642 botan_rng_t rng,
1643 const char* passphrase,
1644 const char* cipher_algo,
1645 const char* pbkdf_algo,
1646 size_t pbkdf_runtime_msec,
1647 botan_view_ctx ctx,
1648 botan_view_str_fn view);
1649
1650typedef struct botan_pubkey_struct* botan_pubkey_t;
1651
1652BOTAN_FFI_EXPORT(2, 0) int botan_pubkey_load(botan_pubkey_t* key, const uint8_t bits[], size_t len);
1653
1655
1656BOTAN_FFI_DEPRECATED("Use botan_pubkey_view_{der,pem,raw}")
1657BOTAN_FFI_EXPORT(2, 0) int botan_pubkey_export(botan_pubkey_t key, uint8_t out[], size_t* out_len, uint32_t flags);
1658
1659/**
1660* View the public key's DER encoding
1661*/
1663
1664/**
1665* View the public key's PEM encoding
1666*/
1668
1669/**
1670* View the public key's raw encoding
1671*/
1673
1674BOTAN_FFI_EXPORT(2, 0) int botan_pubkey_algo_name(botan_pubkey_t key, char out[], size_t* out_len);
1675
1676/**
1677* Returns 0 if key is valid, negative if invalid key or some other error
1678*/
1679BOTAN_FFI_EXPORT(2, 0) int botan_pubkey_check_key(botan_pubkey_t key, botan_rng_t rng, uint32_t flags);
1680
1681BOTAN_FFI_EXPORT(2, 0) int botan_pubkey_estimated_strength(botan_pubkey_t key, size_t* estimate);
1682
1683BOTAN_FFI_EXPORT(2, 0)
1684int botan_pubkey_fingerprint(botan_pubkey_t key, const char* hash, uint8_t out[], size_t* out_len);
1685
1686/**
1687* @return 0 if success, error if invalid object handle
1688*/
1690
1691/*
1692* Get arbitrary named fields from public or private keys
1693*/
1694BOTAN_FFI_EXPORT(2, 0) int botan_pubkey_get_field(botan_mp_t output, botan_pubkey_t key, const char* field_name);
1695
1696BOTAN_FFI_EXPORT(2, 0) int botan_privkey_get_field(botan_mp_t output, botan_privkey_t key, const char* field_name);
1697
1698/*
1699* Get the OID from public or private keys
1700*/
1701BOTAN_FFI_EXPORT(3, 8)
1703
1704BOTAN_FFI_EXPORT(3, 8)
1706
1707/**
1708* Checks whether a key is stateful and sets
1709* @param out to 1 if it is, or 0 if the key is not stateful
1710* @return 0 on success, a negative value on failure
1711*/
1713
1714/**
1715* Gets information on many operations a (stateful) key has remaining and sets
1716* @param out to that value
1717* @return 0 on success, a negative value on failure or if the key is not stateful
1718*/
1720
1721/*
1722* Algorithm specific key operations: RSA
1723*/
1725
1726BOTAN_FFI_EXPORT(2, 8) int botan_privkey_load_rsa_pkcs1(botan_privkey_t* key, const uint8_t bits[], size_t len);
1727
1728BOTAN_FFI_DEPRECATED("Use botan_privkey_get_field")
1730BOTAN_FFI_DEPRECATED("Use botan_privkey_get_field")
1732BOTAN_FFI_DEPRECATED("Use botan_privkey_get_field")
1734BOTAN_FFI_DEPRECATED("Use botan_privkey_get_field")
1736BOTAN_FFI_DEPRECATED("Use botan_privkey_get_field")
1738
1739BOTAN_FFI_EXPORT(2, 8)
1740int botan_privkey_rsa_get_privkey(botan_privkey_t rsa_key, uint8_t out[], size_t* out_len, uint32_t flags);
1741
1743
1744BOTAN_FFI_EXPORT(3, 11) int botan_pubkey_load_rsa_pkcs1(botan_pubkey_t* key, const uint8_t bits[], size_t len);
1745
1746BOTAN_FFI_DEPRECATED("Use botan_pubkey_get_field")
1748BOTAN_FFI_DEPRECATED("Use botan_pubkey_get_field")
1750
1751/*
1752* Algorithm specific key operations: DSA
1753*/
1754BOTAN_FFI_EXPORT(2, 0)
1756
1757BOTAN_FFI_EXPORT(2, 0)
1759
1760BOTAN_FFI_DEPRECATED("Use botan_privkey_get_field")
1762
1763BOTAN_FFI_DEPRECATED("Use botan_pubkey_get_field")
1765BOTAN_FFI_DEPRECATED("Use botan_pubkey_get_field")
1767BOTAN_FFI_DEPRECATED("Use botan_pubkey_get_field")
1769BOTAN_FFI_DEPRECATED("Use botan_pubkey_get_field")
1771
1772/*
1773* Loads Diffie Hellman private key
1774*
1775* @param key variable populated with key material
1776* @param p prime order of a Z_p group
1777* @param g group generator
1778* @param x private key
1779*
1780* @pre key is NULL on input
1781* @post function allocates memory and assigns to `key'
1782*
1783* @return 0 on success, a negative value on failure
1784*/
1786/**
1787* Loads Diffie Hellman public key
1788*
1789* @param key variable populated with key material
1790* @param p prime order of a Z_p group
1791* @param g group generator
1792* @param y public key
1793*
1794* @pre key is NULL on input
1795* @post function allocates memory and assigns to `key'
1796*
1797* @return 0 on success, a negative value on failure
1798*/
1800
1801/*
1802* Algorithm specific key operations: ElGamal
1803*/
1804
1805/**
1806* Loads ElGamal public key
1807* @param key variable populated with key material
1808* @param p prime order of a Z_p group
1809* @param g group generator
1810* @param y public key
1811*
1812* @pre key is NULL on input
1813* @post function allocates memory and assigns to `key'
1814*
1815* @return 0 on success, a negative value on failure
1816*/
1818
1819/**
1820* Loads ElGamal private key
1821*
1822* @param key variable populated with key material
1823* @param p prime order of a Z_p group
1824* @param g group generator
1825* @param x private key
1826*
1827* @pre key is NULL on input
1828* @post function allocates memory and assigns to `key'
1829*
1830* @return 0 on success, a negative value on failure
1831*/
1833
1834/*
1835* Algorithm specific key operations: Ed25519
1836*/
1837
1838BOTAN_FFI_EXPORT(2, 2) int botan_privkey_load_ed25519(botan_privkey_t* key, const uint8_t privkey[32]);
1839
1840BOTAN_FFI_EXPORT(2, 2) int botan_pubkey_load_ed25519(botan_pubkey_t* key, const uint8_t pubkey[32]);
1841
1842BOTAN_FFI_DEPRECATED("Use botan_privkey_view_raw")
1843BOTAN_FFI_EXPORT(2, 2) int botan_privkey_ed25519_get_privkey(botan_privkey_t key, uint8_t output[64]);
1844
1845BOTAN_FFI_DEPRECATED("Use botan_pubkey_view_raw")
1846BOTAN_FFI_EXPORT(2, 2) int botan_pubkey_ed25519_get_pubkey(botan_pubkey_t key, uint8_t pubkey[32]);
1847
1848/*
1849* Algorithm specific key operations: Ed448
1850*/
1851
1852BOTAN_FFI_EXPORT(3, 4) int botan_privkey_load_ed448(botan_privkey_t* key, const uint8_t privkey[57]);
1853
1854BOTAN_FFI_EXPORT(3, 4) int botan_pubkey_load_ed448(botan_pubkey_t* key, const uint8_t pubkey[57]);
1855
1856BOTAN_FFI_DEPRECATED("Use botan_privkey_view_raw")
1857BOTAN_FFI_EXPORT(3, 4) int botan_privkey_ed448_get_privkey(botan_privkey_t key, uint8_t output[57]);
1858
1859BOTAN_FFI_DEPRECATED("Use botan_pubkey_view_raw")
1860BOTAN_FFI_EXPORT(3, 4) int botan_pubkey_ed448_get_pubkey(botan_pubkey_t key, uint8_t pubkey[57]);
1861
1862/*
1863* Algorithm specific key operations: X25519
1864*/
1865
1866BOTAN_FFI_EXPORT(2, 8) int botan_privkey_load_x25519(botan_privkey_t* key, const uint8_t privkey[32]);
1867
1868BOTAN_FFI_EXPORT(2, 8) int botan_pubkey_load_x25519(botan_pubkey_t* key, const uint8_t pubkey[32]);
1869
1870BOTAN_FFI_DEPRECATED("Use botan_privkey_view_raw")
1871BOTAN_FFI_EXPORT(2, 8) int botan_privkey_x25519_get_privkey(botan_privkey_t key, uint8_t output[32]);
1872
1873BOTAN_FFI_DEPRECATED("Use botan_pubkey_view_raw")
1874BOTAN_FFI_EXPORT(2, 8) int botan_pubkey_x25519_get_pubkey(botan_pubkey_t key, uint8_t pubkey[32]);
1875
1876/*
1877* Algorithm specific key operations: X448
1878*/
1879
1880BOTAN_FFI_EXPORT(3, 4) int botan_privkey_load_x448(botan_privkey_t* key, const uint8_t privkey[56]);
1881
1882BOTAN_FFI_EXPORT(3, 4) int botan_pubkey_load_x448(botan_pubkey_t* key, const uint8_t pubkey[56]);
1883
1884BOTAN_FFI_DEPRECATED("Use botan_privkey_view_raw")
1885BOTAN_FFI_EXPORT(3, 4) int botan_privkey_x448_get_privkey(botan_privkey_t key, uint8_t output[56]);
1886
1887BOTAN_FFI_DEPRECATED("Use botan_pubkey_view_raw")
1888BOTAN_FFI_EXPORT(3, 4) int botan_pubkey_x448_get_pubkey(botan_pubkey_t key, uint8_t pubkey[56]);
1889
1890/*
1891* Algorithm specific key operations: ML-DSA
1892*/
1893
1894BOTAN_FFI_EXPORT(3, 6)
1895int botan_privkey_load_ml_dsa(botan_privkey_t* key, const uint8_t privkey[], size_t key_len, const char* mldsa_mode);
1896
1897BOTAN_FFI_EXPORT(3, 6)
1898int botan_pubkey_load_ml_dsa(botan_pubkey_t* key, const uint8_t pubkey[], size_t key_len, const char* mldsa_mode);
1899
1900/*
1901* Algorithm specific key operations: Kyber R3
1902*
1903* Note that Kyber R3 support is somewhat deprecated and may be removed in a
1904* future major release. Using the final ML-KEM is highly recommended in any new
1905* system.
1906*/
1907
1908BOTAN_FFI_DEPRECATED("Kyber R3 support is deprecated")
1909BOTAN_FFI_EXPORT(3, 1) int botan_privkey_load_kyber(botan_privkey_t* key, const uint8_t privkey[], size_t key_len);
1910
1911BOTAN_FFI_DEPRECATED("Kyber R3 support is deprecated")
1912BOTAN_FFI_EXPORT(3, 1) int botan_pubkey_load_kyber(botan_pubkey_t* key, const uint8_t pubkey[], size_t key_len);
1913
1914BOTAN_FFI_DEPRECATED("Use generic botan_privkey_view_raw")
1915BOTAN_FFI_EXPORT(3, 1)
1917
1918BOTAN_FFI_DEPRECATED("Use generic botan_pubkey_view_raw")
1919BOTAN_FFI_EXPORT(3, 1)
1921
1922/**
1923* Algorithm specific key operation: FrodoKEM
1924*/
1925
1926BOTAN_FFI_EXPORT(3, 6)
1927int botan_privkey_load_frodokem(botan_privkey_t* key, const uint8_t privkey[], size_t key_len, const char* frodo_mode);
1928
1929BOTAN_FFI_EXPORT(3, 6)
1930int botan_pubkey_load_frodokem(botan_pubkey_t* key, const uint8_t pubkey[], size_t key_len, const char* frodo_mode);
1931
1932/**
1933* Algorithm specific key operation: Classic McEliece
1934*/
1935
1936BOTAN_FFI_EXPORT(3, 6)
1938 const uint8_t privkey[],
1939 size_t key_len,
1940 const char* cmce_mode);
1941
1942BOTAN_FFI_EXPORT(3, 6)
1944 const uint8_t pubkey[],
1945 size_t key_len,
1946 const char* cmce_mode);
1947
1948/*
1949* Algorithm specific key operations: ML-KEM
1950*/
1951
1952BOTAN_FFI_EXPORT(3, 6)
1953int botan_privkey_load_ml_kem(botan_privkey_t* key, const uint8_t privkey[], size_t key_len, const char* mlkem_mode);
1954
1955BOTAN_FFI_EXPORT(3, 6)
1956int botan_pubkey_load_ml_kem(botan_pubkey_t* key, const uint8_t pubkey[], size_t key_len, const char* mlkem_mode);
1957
1958/*
1959* Algorithm specific key operations: SLH-DSA
1960*/
1961
1962BOTAN_FFI_EXPORT(3, 6)
1963int botan_privkey_load_slh_dsa(botan_privkey_t* key, const uint8_t privkey[], size_t key_len, const char* slhdsa_mode);
1964
1965BOTAN_FFI_EXPORT(3, 6)
1966int botan_pubkey_load_slh_dsa(botan_pubkey_t* key, const uint8_t pubkey[], size_t key_len, const char* slhdsa_mode);
1967
1968/*
1969* Algorithm specific key operations: ECDSA and ECDH
1970*/
1971BOTAN_FFI_EXPORT(3, 2)
1973
1974BOTAN_FFI_EXPORT(2, 2)
1975int botan_privkey_load_ecdsa(botan_privkey_t* key, botan_mp_t scalar, const char* curve_name);
1976
1977BOTAN_FFI_EXPORT(2, 2)
1978int botan_pubkey_load_ecdsa(botan_pubkey_t* key, botan_mp_t public_x, botan_mp_t public_y, const char* curve_name);
1979
1980BOTAN_FFI_EXPORT(3, 10)
1981int botan_pubkey_load_ecdsa_sec1(botan_pubkey_t* key, const uint8_t sec1[], size_t sec1_len, const char* curve_name);
1982
1983BOTAN_FFI_EXPORT(2, 2)
1984int botan_pubkey_load_ecdh(botan_pubkey_t* key, botan_mp_t public_x, botan_mp_t public_y, const char* curve_name);
1985
1986BOTAN_FFI_EXPORT(3, 10)
1987int botan_pubkey_load_ecdh_sec1(botan_pubkey_t* key, const uint8_t sec1[], size_t sec1_len, const char* curve_name);
1988
1989BOTAN_FFI_EXPORT(2, 2)
1990int botan_privkey_load_ecdh(botan_privkey_t* key, botan_mp_t scalar, const char* curve_name);
1991
1992BOTAN_FFI_EXPORT(2, 2)
1993int botan_pubkey_load_sm2(botan_pubkey_t* key, botan_mp_t public_x, botan_mp_t public_y, const char* curve_name);
1994
1995BOTAN_FFI_EXPORT(3, 10)
1996int botan_pubkey_load_sm2_sec1(botan_pubkey_t* key, const uint8_t sec1[], size_t sec1_len, const char* curve_name);
1997
1998BOTAN_FFI_EXPORT(2, 2)
1999int botan_privkey_load_sm2(botan_privkey_t* key, botan_mp_t scalar, const char* curve_name);
2000
2001BOTAN_FFI_DEPRECATED("Use botan_pubkey_load_sm2")
2002BOTAN_FFI_EXPORT(2, 2)
2003int botan_pubkey_load_sm2_enc(botan_pubkey_t* key, botan_mp_t public_x, botan_mp_t public_y, const char* curve_name);
2004
2005BOTAN_FFI_DEPRECATED("Use botan_privkey_load_sm2")
2006BOTAN_FFI_EXPORT(2, 2)
2007int botan_privkey_load_sm2_enc(botan_privkey_t* key, botan_mp_t scalar, const char* curve_name);
2008
2009BOTAN_FFI_EXPORT(2, 3)
2011 uint8_t out[], size_t* out_len, const char* ident, const char* hash_algo, botan_pubkey_t key);
2012
2013/**
2014* View the uncompressed public point associated with the key
2015*/
2016BOTAN_FFI_EXPORT(3, 0)
2018
2019/*
2020* Public Key Encryption
2021*/
2022typedef struct botan_pk_op_encrypt_struct* botan_pk_op_encrypt_t;
2023
2024BOTAN_FFI_EXPORT(2, 0)
2025int botan_pk_op_encrypt_create(botan_pk_op_encrypt_t* op, botan_pubkey_t key, const char* padding, uint32_t flags);
2026
2027/**
2028* @return 0 if success, error if invalid object handle
2029*/
2031
2032BOTAN_FFI_EXPORT(2, 8)
2033int botan_pk_op_encrypt_output_length(botan_pk_op_encrypt_t op, size_t ptext_len, size_t* ctext_len);
2034
2035BOTAN_FFI_EXPORT(2, 0)
2037 botan_rng_t rng,
2038 uint8_t out[],
2039 size_t* out_len,
2040 const uint8_t plaintext[],
2041 size_t plaintext_len);
2042
2043/*
2044* Public Key Decryption
2045*/
2046typedef struct botan_pk_op_decrypt_struct* botan_pk_op_decrypt_t;
2047
2048BOTAN_FFI_EXPORT(2, 0)
2049int botan_pk_op_decrypt_create(botan_pk_op_decrypt_t* op, botan_privkey_t key, const char* padding, uint32_t flags);
2050
2051/**
2052* @return 0 if success, error if invalid object handle
2053*/
2055
2056BOTAN_FFI_EXPORT(2, 8)
2057int botan_pk_op_decrypt_output_length(botan_pk_op_decrypt_t op, size_t ctext_len, size_t* ptext_len);
2058
2059BOTAN_FFI_EXPORT(2, 0)
2061 botan_pk_op_decrypt_t op, uint8_t out[], size_t* out_len, const uint8_t ciphertext[], size_t ciphertext_len);
2062
2063/*
2064* Signature Generation
2065*/
2066
2067#define BOTAN_PUBKEY_DER_FORMAT_SIGNATURE 1
2068
2069typedef struct botan_pk_op_sign_struct* botan_pk_op_sign_t;
2070
2071BOTAN_FFI_EXPORT(2, 0)
2072int botan_pk_op_sign_create(botan_pk_op_sign_t* op, botan_privkey_t key, const char* hash_and_padding, uint32_t flags);
2073
2074/**
2075* @return 0 if success, error if invalid object handle
2076*/
2078
2080
2081BOTAN_FFI_EXPORT(2, 0) int botan_pk_op_sign_update(botan_pk_op_sign_t op, const uint8_t in[], size_t in_len);
2082
2083BOTAN_FFI_EXPORT(2, 0)
2084int botan_pk_op_sign_finish(botan_pk_op_sign_t op, botan_rng_t rng, uint8_t sig[], size_t* sig_len);
2085
2086/*
2087* Signature Verification
2088*/
2089typedef struct botan_pk_op_verify_struct* botan_pk_op_verify_t;
2090
2091BOTAN_FFI_EXPORT(2, 0)
2093 botan_pubkey_t key,
2094 const char* hash_and_padding,
2095 uint32_t flags);
2096
2097/**
2098* @return 0 if success, error if invalid object handle
2099*/
2101
2102BOTAN_FFI_EXPORT(2, 0) int botan_pk_op_verify_update(botan_pk_op_verify_t op, const uint8_t in[], size_t in_len);
2103BOTAN_FFI_EXPORT(2, 0) int botan_pk_op_verify_finish(botan_pk_op_verify_t op, const uint8_t sig[], size_t sig_len);
2104
2105/*
2106* Key Agreement
2107*/
2108typedef struct botan_pk_op_ka_struct* botan_pk_op_ka_t;
2109
2110BOTAN_FFI_EXPORT(2, 0)
2111int botan_pk_op_key_agreement_create(botan_pk_op_ka_t* op, botan_privkey_t key, const char* kdf, uint32_t flags);
2112
2113/**
2114* @return 0 if success, error if invalid object handle
2115*/
2117
2118BOTAN_FFI_EXPORT(2, 0) int botan_pk_op_key_agreement_export_public(botan_privkey_t key, uint8_t out[], size_t* out_len);
2119
2120BOTAN_FFI_EXPORT(3, 0)
2122
2124
2125BOTAN_FFI_EXPORT(2, 0)
2127 uint8_t out[],
2128 size_t* out_len,
2129 const uint8_t other_key[],
2130 size_t other_key_len,
2131 const uint8_t salt[],
2132 size_t salt_len);
2133
2134/*
2135* Key Encapsulation
2136*/
2137typedef struct botan_pk_op_kem_encrypt_struct* botan_pk_op_kem_encrypt_t;
2138
2139BOTAN_FFI_EXPORT(3, 0)
2141
2142/**
2143* @return 0 if success, error if invalid object handle
2144*/
2146
2147BOTAN_FFI_EXPORT(3, 0)
2149 size_t desired_shared_key_length,
2150 size_t* output_shared_key_length);
2151
2152BOTAN_FFI_EXPORT(3, 0)
2154 size_t* output_encapsulated_key_length);
2155
2156BOTAN_FFI_EXPORT(3, 0)
2158 botan_rng_t rng,
2159 const uint8_t salt[],
2160 size_t salt_len,
2161 size_t desired_shared_key_len,
2162 uint8_t shared_key[],
2163 size_t* shared_key_len,
2164 uint8_t encapsulated_key[],
2165 size_t* encapsulated_key_len);
2166
2167typedef struct botan_pk_op_kem_decrypt_struct* botan_pk_op_kem_decrypt_t;
2168
2169BOTAN_FFI_EXPORT(3, 0)
2171
2172/**
2173* @return 0 if success, error if invalid object handle
2174*/
2176
2177BOTAN_FFI_EXPORT(3, 0)
2179 size_t desired_shared_key_length,
2180 size_t* output_shared_key_length);
2181
2182BOTAN_FFI_EXPORT(3, 0)
2184 const uint8_t salt[],
2185 size_t salt_len,
2186 const uint8_t encapsulated_key[],
2187 size_t encapsulated_key_len,
2188 size_t desired_shared_key_len,
2189 uint8_t shared_key[],
2190 size_t* shared_key_len);
2191
2192/**
2193* Signature Scheme Utility Functions
2194*/
2195
2196BOTAN_FFI_EXPORT(2, 0) int botan_pkcs_hash_id(const char* hash_name, uint8_t pkcs_id[], size_t* pkcs_id_len);
2197
2198/*
2199* Always returns BOTAN_FFI_ERROR_NOT_IMPLEMENTED
2200*/
2201BOTAN_FFI_DEPRECATED("No longer implemented")
2202BOTAN_FFI_EXPORT(2, 0)
2204 botan_rng_t rng,
2205 const char* aead,
2206 const uint8_t pt[],
2207 size_t pt_len,
2208 const uint8_t ad[],
2209 size_t ad_len,
2210 uint8_t ct[],
2211 size_t* ct_len);
2212
2213/*
2214* Always returns BOTAN_FFI_ERROR_NOT_IMPLEMENTED
2215*/
2216BOTAN_FFI_DEPRECATED("No longer implemented")
2217BOTAN_FFI_EXPORT(2, 0)
2219 const char* aead,
2220 const uint8_t ct[],
2221 size_t ct_len,
2222 const uint8_t ad[],
2223 size_t ad_len,
2224 uint8_t pt[],
2225 size_t* pt_len);
2226
2227/*
2228* X.509 certificates
2229**************************/
2230
2231typedef struct botan_x509_cert_struct* botan_x509_cert_t;
2232
2233/**
2234 * Generic values that may be retrieved from X.509 certificates or CRLs via
2235 * the generic getter functions.
2236 *
2237 * When extending this list the existing entries must stay backward-compatible
2238 * to remain ABI compatible across versions. Therefore, new values must be added
2239 * to the end of this list.
2240 *
2241 * See:
2242 * * botan_x509_cert_view_binary_values()
2243 * * botan_x509_crl_view_binary_values()
2244 * * botan_x509_cert_view_string_values()
2245 */
2246typedef enum /* NOLINT(*-enum-size,*-use-enum-class) */ {
2247 BOTAN_X509_SERIAL_NUMBER = 0, /** singleton binary big-endian encoding */
2248 BOTAN_X509_SUBJECT_DN_BITS = 1, /** singleton binary DER encoding of the subject distinguished name */
2249 BOTAN_X509_ISSUER_DN_BITS = 2, /** singleton binary DER encoding of the issuer distinguished name */
2250 BOTAN_X509_SUBJECT_KEY_IDENTIFIER = 3, /** singleton binary encoding */
2251 BOTAN_X509_AUTHORITY_KEY_IDENTIFIER = 4, /** singleton binary encoding */
2252
2253 BOTAN_X509_PUBLIC_KEY_PKCS8_BITS = 200, /** singleton binary DER encoding of the PKCS#8 public key */
2254 BOTAN_X509_TBS_DATA_BITS = 201, /** singleton binary DER encoding */
2255 BOTAN_X509_SIGNATURE_SCHEME_BITS = 202, /** singleton binary DER encoding of the algorithm identifier */
2256 BOTAN_X509_SIGNATURE_BITS = 203, /** singleton binary signature bits */
2257
2258 BOTAN_X509_DER_ENCODING = 300, /** singleton binary DER encoding of the whole object */
2259 BOTAN_X509_PEM_ENCODING = 301, /** singleton string value PEM encoding of the whole object */
2260
2261 BOTAN_X509_CRL_DISTRIBUTION_URLS = 400, /** multi-value string of the CRL distribution points */
2262 BOTAN_X509_OCSP_RESPONDER_URLS = 401, /** multi-value string of the OCSP responder URLs */
2263 BOTAN_X509_CA_ISSUERS_URLS = 402, /** multi-value string of the CA issuer URLs */
2265
2266BOTAN_FFI_EXPORT(2, 0) int botan_x509_cert_load(botan_x509_cert_t* cert_obj, const uint8_t cert[], size_t cert_len);
2267BOTAN_FFI_EXPORT(2, 0) int botan_x509_cert_load_file(botan_x509_cert_t* cert_obj, const char* filename);
2268
2269/**
2270* @return 0 if success, error if invalid object handle
2271*/
2273
2275
2276/**
2277 * Retrieve a specific binary value from an X.509 certificate.
2278 *
2279 * For multi-values @p index allows enumerating the available entries, until
2280 * BOTAN_FFI_ERROR_OUT_OF_RANGE is returned. For singleton values, an @p index
2281 * of value "0" is expected.
2282 *
2283 * @returns BOTAN_FFI_ERROR_NO_VALUE if the provided @p cert does not provide
2284 * the requested @p value_type at all or not in binary format.
2285 */
2286BOTAN_FFI_EXPORT(3, 11)
2288 botan_x509_cert_t cert, botan_x509_value_type value_type, size_t index, botan_view_ctx ctx, botan_view_bin_fn view);
2289BOTAN_FFI_EXPORT(3, 11)
2291
2292/**
2293 * Retrieve a specific string value from an X.509 certificate.
2294 *
2295 * For multi-values @p index allows enumerating the available entries, until
2296 * BOTAN_FFI_ERROR_OUT_OF_RANGE is returned. For singleton values, an @p index
2297 * of value "0" is expected.
2298 *
2299 * @returns BOTAN_FFI_ERROR_NO_VALUE if the provided @p cert does not provide
2300 * the requested @p value_type at all or not in string format.
2301 */
2302BOTAN_FFI_EXPORT(3, 11)
2304 botan_x509_cert_t cert, botan_x509_value_type value_type, size_t index, botan_view_ctx ctx, botan_view_str_fn view);
2305BOTAN_FFI_EXPORT(3, 11)
2307
2308/* Prefer botan_x509_cert_not_before and botan_x509_cert_not_after */
2309BOTAN_FFI_EXPORT(2, 0) int botan_x509_cert_get_time_starts(botan_x509_cert_t cert, char out[], size_t* out_len);
2310BOTAN_FFI_EXPORT(2, 0) int botan_x509_cert_get_time_expires(botan_x509_cert_t cert, char out[], size_t* out_len);
2311
2312BOTAN_FFI_EXPORT(2, 8) int botan_x509_cert_not_before(botan_x509_cert_t cert, uint64_t* time_since_epoch);
2313BOTAN_FFI_EXPORT(2, 8) int botan_x509_cert_not_after(botan_x509_cert_t cert, uint64_t* time_since_epoch);
2314
2315/* TODO(Botan4) this should use char for the out param */
2316BOTAN_FFI_EXPORT(2, 0)
2317int botan_x509_cert_get_fingerprint(botan_x509_cert_t cert, const char* hash, uint8_t out[], size_t* out_len);
2318
2319BOTAN_FFI_EXPORT(2, 0) int botan_x509_cert_get_serial_number(botan_x509_cert_t cert, uint8_t out[], size_t* out_len);
2321BOTAN_FFI_EXPORT(2, 0) int botan_x509_cert_get_authority_key_id(botan_x509_cert_t cert, uint8_t out[], size_t* out_len);
2322BOTAN_FFI_EXPORT(2, 0) int botan_x509_cert_get_subject_key_id(botan_x509_cert_t cert, uint8_t out[], size_t* out_len);
2323
2324BOTAN_FFI_EXPORT(2, 0) int botan_x509_cert_get_public_key_bits(botan_x509_cert_t cert, uint8_t out[], size_t* out_len);
2325
2326BOTAN_FFI_EXPORT(3, 0)
2328
2330
2331/**
2332 * Returns 1 iff the cert is a CA certificate
2333 */
2335
2336/**
2337 * Retrieves the path length constraint from the certificate.
2338 * If no such constraint is present, BOTAN_FFI_ERROR_NO_VALUE is returned.
2339 */
2341
2342/**
2343 * Enumerates the names of the given @p key in the issuer DN. If @p index is
2344 * out of bounds, BOTAN_FFI_ERROR_BAD_PARAMETER is returned.
2345 *
2346 * TODO(Botan4) use BOTAN_FFI_ERROR_OUT_OF_RANGE instead of BAD_PARAMETER
2347 * TODO(Botan4) this should use char for the out param
2348 */
2349BOTAN_FFI_EXPORT(2, 0)
2351 botan_x509_cert_t cert, const char* key, size_t index, uint8_t out[], size_t* out_len);
2352BOTAN_FFI_EXPORT(3, 11) int botan_x509_cert_get_issuer_dn_count(botan_x509_cert_t cert, const char* key, size_t* count);
2353
2354/**
2355 * Enumerates the names of the given @p key in the subject DN. If @p index is
2356 * out of bounds, BOTAN_FFI_ERROR_BAD_PARAMETER is returned.
2357 *
2358 * TODO(Botan4) use BOTAN_FFI_ERROR_OUT_OF_RANGE instead of BAD_PARAMETER
2359 * TODO(Botan4) this should use char for the out param
2360 */
2361BOTAN_FFI_EXPORT(2, 0)
2363 botan_x509_cert_t cert, const char* key, size_t index, uint8_t out[], size_t* out_len);
2364BOTAN_FFI_EXPORT(3, 11)
2365int botan_x509_cert_get_subject_dn_count(botan_x509_cert_t cert, const char* key, size_t* count);
2366
2367BOTAN_FFI_EXPORT(2, 0) int botan_x509_cert_to_string(botan_x509_cert_t cert, char out[], size_t* out_len);
2368
2369BOTAN_FFI_EXPORT(3, 0)
2371
2372/* Must match values of Key_Constraints in pkix_enums.h */
2385
2386BOTAN_FFI_EXPORT(2, 0) int botan_x509_cert_allowed_usage(botan_x509_cert_t cert, unsigned int key_usage);
2387
2388/**
2389* Check if the certificate allows the specified extended usage OID. See RFC 5280
2390* Section 4.2.1.12 for OIDs to query for this. If no extended key usage
2391* extension is found in the certificate, this always returns "not success".
2392*
2393* Typical OIDs to check for:
2394* * "PKIX.ServerAuth"
2395* * "PKIX.ClientAuth"
2396* * "PKIX.CodeSigning"
2397* * "PKIX.OCSPSigning"
2398*
2399* The @p oid parameter can be either a canonical OID string or identifiers as
2400* indicated in the examples above.
2401*/
2403
2404/**
2405* Check if the certificate allows the specified extended usage OID. See RFC 5280
2406* Section 4.2.1.12 for OIDs to query for this. If no extended key usage
2407* extension is found in the certificate, this always returns "not success".
2408*
2409* This is similar to botan_x509_cert_allowed_extended_usage_str but takes an OID
2410* object instead of a string describing the OID.
2411*/
2413
2414typedef struct botan_x509_general_name_struct* botan_x509_general_name_t;
2415
2416/**
2417* GeneralName type identifiers as defined in RFC 5280 A.2 (GeneralName ::= CHOICE)
2418* Type identifiers that are omitted here are (currently) not supported. Also,
2419* there is currently no way to access OTHER_NAME values via the FFI.
2420*/
2429
2430/**
2431* Provides the contained type of the @p name and returns BOTAN_FFI_SUCCESS if
2432* that type is supported and may be retrieved via the view functions below.
2433* Otherwise BOTAN_FFI_ERROR_INVALID_OBJECT_STATE is returned.
2434*/
2436
2437/**
2438* Views the name as a string or returns BOTAN_FFI_ERROR_INVALID_OBJECT_STATE
2439* if the contained GeneralName value cannot be represented as a string.
2440*
2441* The types BOTAN_X509_EMAIL_ADDRESS, BOTAN_X509_DNS_NAME, BOTAN_X509_URI,
2442* BOTAN_X509_IP_ADDRESS may be viewed as "string".
2443*/
2444BOTAN_FFI_EXPORT(3, 11)
2446 botan_view_ctx ctx,
2447 botan_view_str_fn view);
2448
2449/**
2450* Views the name as a bit string or returns BOTAN_FFI_ERROR_INVALID_OBJECT_STATE
2451* if the contained GeneralName value cannot be represented as a binary string.
2452*
2453* The types BOTAN_X509_DIRECTORY_NAME, BOTAN_X509_IP_ADDRESS may be viewed as
2454* "binary".
2455*/
2456BOTAN_FFI_EXPORT(3, 11)
2458 botan_view_ctx ctx,
2459 botan_view_bin_fn view);
2460
2462
2463/**
2464* Extracts "permitted" name constraints from a given @p cert one-by-one.
2465* Returns BOTAN_FFI_ERROR_OUT_OF_RANGE if the given @p index is larger than the
2466* available number of "permitted" name constraints.
2467*/
2468BOTAN_FFI_EXPORT(3, 11)
2470 size_t index,
2471 botan_x509_general_name_t* constraint);
2473
2474/**
2475* Extracts "excluded" name constraints from a given @p cert one-by-one.
2476* Returns BOTAN_FFI_ERROR_OUT_OF_RANGE if the given @p index is larger than the
2477* available number of "excluded" name constraints.
2478*/
2479BOTAN_FFI_EXPORT(3, 11)
2481 size_t index,
2482 botan_x509_general_name_t* constraint);
2484
2485/**
2486* Provides access to all "subject alternative names", where each entry is
2487* returned as a botan_x509_general_name_t. If the given @p index is not
2488* within range of the available entries, BOTAN_FFI_ERROR_OUT_OF_RANGE is
2489* returned. If @p cert does not contain a SubjectAlternativeNames extension,
2490* BOTAN_FFI_ERROR_NO_VALUE is returned.
2491*/
2492BOTAN_FFI_EXPORT(3, 11)
2494 size_t index,
2495 botan_x509_general_name_t* alt_name);
2497
2498/**
2499* Provides access to all "issuer alternative names", where each entry is
2500* returned as a botan_x509_general_name_t. If the given @p index is not
2501* within range of the available entries, BOTAN_FFI_ERROR_OUT_OF_RANGE is
2502* returned. If @p cert does not contain an IssuerAlternativeNames extension,
2503* BOTAN_FFI_ERROR_NO_VALUE is returned.
2504*/
2505BOTAN_FFI_EXPORT(3, 11)
2508
2509/**
2510* Check if the certificate matches the specified hostname via alternative name or CN match.
2511* RFC 5280 wildcards also supported.
2512*/
2513BOTAN_FFI_EXPORT(2, 5) int botan_x509_cert_hostname_match(botan_x509_cert_t cert, const char* hostname);
2514
2515/**
2516* Returns 0 if the validation was successful, 1 if validation failed,
2517* and negative on error. A status code with details is written to
2518* *validation_result
2519*
2520* Intermediates or trusted lists can be null
2521* Trusted path can be null
2522*/
2523BOTAN_FFI_EXPORT(2, 8)
2524int botan_x509_cert_verify(int* validation_result,
2525 botan_x509_cert_t cert,
2526 const botan_x509_cert_t* intermediates,
2527 size_t intermediates_len,
2528 const botan_x509_cert_t* trusted,
2529 size_t trusted_len,
2530 const char* trusted_path,
2531 size_t required_strength,
2532 const char* hostname,
2533 uint64_t reference_time);
2534
2535/**
2536* Returns a pointer to a static character string explaining the status code,
2537* or else NULL if unknown.
2538*/
2539BOTAN_FFI_EXPORT(2, 8) const char* botan_x509_cert_validation_status(int code);
2540
2541/*
2542* X.509 CRL
2543**************************/
2544
2545typedef struct botan_x509_crl_struct* botan_x509_crl_t;
2546typedef struct botan_x509_crl_entry_struct* botan_x509_crl_entry_t;
2547
2548BOTAN_FFI_EXPORT(2, 13) int botan_x509_crl_load_file(botan_x509_crl_t* crl_obj, const char* crl_path);
2549BOTAN_FFI_EXPORT(2, 13)
2550int botan_x509_crl_load(botan_x509_crl_t* crl_obj, const uint8_t crl_bits[], size_t crl_bits_len);
2551
2552BOTAN_FFI_EXPORT(3, 11) int botan_x509_crl_this_update(botan_x509_crl_t crl, uint64_t* time_since_epoch);
2553BOTAN_FFI_EXPORT(3, 11) int botan_x509_crl_next_update(botan_x509_crl_t crl, uint64_t* time_since_epoch);
2554
2555/**
2556* Create a new CRL
2557* @param crl_obj The newly created CRL
2558* @param rng a random number generator object
2559* @param ca_cert The CA Certificate the CRL belongs to
2560* @param ca_key The private key of that CA
2561* @param issue_time The time when the CRL becomes valid
2562* @param next_update The number of seconds after issue_time until the CRL expires
2563* @param hash_fn The hash function to use, may be null
2564* @param padding The padding to use, may be null
2565*/
2566BOTAN_FFI_EXPORT(3, 11)
2568 botan_rng_t rng,
2569 botan_x509_cert_t ca_cert,
2570 botan_privkey_t ca_key,
2571 uint64_t issue_time,
2572 uint32_t next_update,
2573 const char* hash_fn,
2574 const char* padding);
2575
2576/* Must match values of CRL_Code in pkix_enums.h */
2589
2590/**
2591* Create a new CRL entry that marks @p cert as revoked
2592* @param entry The newly created CRL entry
2593* @param cert The certificate to mark as revoked
2594* @param reason_code The reason code for revocation
2595*/
2596BOTAN_FFI_EXPORT(3, 11)
2598
2599/**
2600* Update a CRL with new revoked entries. This does not modify the old crl, and instead creates a new one.
2601* @param crl_obj The newly created CRL
2602* @param last_crl The CRL to update
2603* @param rng a random number generator object
2604* @param ca_cert The CA Certificate the CRL belongs to
2605* @param ca_key The private key of that CA
2606* @param issue_time The time when the CRL becomes valid
2607* @param next_update The number of seconds after issue_time until the CRL expires
2608* @param new_entries The entries to add to the CRL
2609* @param new_entries_len The number of entries
2610* @param hash_fn The hash function to use, may be null
2611* @param padding The padding to use, may be null
2612*/
2613BOTAN_FFI_EXPORT(3, 11)
2615 botan_x509_crl_t last_crl,
2616 botan_rng_t rng,
2617 botan_x509_cert_t ca_cert,
2618 botan_privkey_t ca_key,
2619 uint64_t issue_time,
2620 uint32_t next_update,
2621 const botan_x509_crl_entry_t* new_entries,
2622 size_t new_entries_len,
2623 const char* hash_fn,
2624 const char* padding);
2625
2627
2629
2630/**
2631 * Retrieve a specific binary value from an X.509 certificate revocation list.
2632 *
2633 * For multi-values @p index allows enumerating the available entries, until
2634 * BOTAN_FFI_ERROR_OUT_OF_RANGE is returned. For singleton values, an @p index
2635 * of value "0" is expected.
2636 *
2637 * @returns BOTAN_FFI_ERROR_NO_VALUE if the provided @p crl_obj does not provide
2638 * the requested @p value_type at all or not in binary format.
2639 */
2640BOTAN_FFI_EXPORT(3, 11)
2642 botan_x509_value_type value_type,
2643 size_t index,
2644 botan_view_ctx ctx,
2645 botan_view_bin_fn view);
2646BOTAN_FFI_EXPORT(3, 11)
2648
2649/**
2650 * Retrieve a specific string value from an X.509 certificate revocation list.
2651 *
2652 * For multi-values @p index allows enumerating the available entries, until
2653 * BOTAN_FFI_ERROR_OUT_OF_RANGE is returned. For singleton values, an @p index
2654 * of value "0" is expected.
2655 *
2656 * @returns BOTAN_FFI_ERROR_NO_VALUE if the provided @p crl_obj does not provide
2657 * the requested @p value_type at all or not in string format.
2658 */
2659BOTAN_FFI_EXPORT(3, 11)
2661 botan_x509_value_type value_type,
2662 size_t index,
2663 botan_view_ctx ctx,
2664 botan_view_str_fn view);
2665BOTAN_FFI_EXPORT(3, 11)
2667
2668/**
2669 * Given a CRL and a certificate,
2670 * check if the certificate is revoked on that particular CRL
2671 */
2673
2674/**
2675* Allows iterating all entries of the CRL.
2676*
2677* @param crl the CRL whose entries should be listed
2678* @param index the index of the CRL entry to return
2679* @param entry an object handle containing the CRL entry data
2680*
2681* @returns BOTAN_FFI_ERROR_OUT_OF_RANGE if the given @p index is out of range of
2682* the CRL entry list.
2683*/
2684BOTAN_FFI_EXPORT(3, 11)
2687
2688/**
2689* Return the revocation reason code for the given CRL @p entry.
2690* See `botan_x509_crl_reason_code` and RFC 5280 - 5.3.1 for possible reason codes.
2691*/
2692BOTAN_FFI_EXPORT(3, 11) int botan_x509_crl_entry_reason(botan_x509_crl_entry_t entry, int* reason_code);
2693
2694/**
2695* Return the revocation date for the given CRL @p entry as time since epoch
2696* in seconds.
2697*/
2698BOTAN_FFI_EXPORT(3, 11)
2699int botan_x509_crl_entry_revocation_date(botan_x509_crl_entry_t entry, uint64_t* time_since_epoch);
2700
2701/**
2702* Return the serial number associated with the given CRL @p entry.
2703*/
2704BOTAN_FFI_EXPORT(3, 11)
2706
2707/**
2708* View the serial number associated with the given CRL @p entry.
2709*/
2710BOTAN_FFI_EXPORT(3, 11)
2712
2714
2715/**
2716 * Different flavor of `botan_x509_cert_verify`, supports revocation lists.
2717 * CRLs are passed as an array, same as intermediates and trusted CAs
2718 */
2719BOTAN_FFI_EXPORT(2, 13)
2720int botan_x509_cert_verify_with_crl(int* validation_result,
2721 botan_x509_cert_t cert,
2722 const botan_x509_cert_t* intermediates,
2723 size_t intermediates_len,
2724 const botan_x509_cert_t* trusted,
2725 size_t trusted_len,
2726 const botan_x509_crl_t* crls,
2727 size_t crls_len,
2728 const char* trusted_path,
2729 size_t required_strength,
2730 const char* hostname,
2731 uint64_t reference_time);
2732
2733/**
2734 * Key wrapping as per RFC 3394
2735 */
2736BOTAN_FFI_DEPRECATED("Use botan_nist_kw_enc")
2737BOTAN_FFI_EXPORT(2, 2)
2738int botan_key_wrap3394(const uint8_t key[],
2739 size_t key_len,
2740 const uint8_t kek[],
2741 size_t kek_len,
2742 uint8_t wrapped_key[],
2743 size_t* wrapped_key_len);
2744
2745BOTAN_FFI_DEPRECATED("Use botan_nist_kw_dec")
2746BOTAN_FFI_EXPORT(2, 2)
2747int botan_key_unwrap3394(const uint8_t wrapped_key[],
2748 size_t wrapped_key_len,
2749 const uint8_t kek[],
2750 size_t kek_len,
2751 uint8_t key[],
2752 size_t* key_len);
2753
2754BOTAN_FFI_EXPORT(3, 0)
2755int botan_nist_kw_enc(const char* cipher_algo,
2756 int padded,
2757 const uint8_t key[],
2758 size_t key_len,
2759 const uint8_t kek[],
2760 size_t kek_len,
2761 uint8_t wrapped_key[],
2762 size_t* wrapped_key_len);
2763
2764BOTAN_FFI_EXPORT(3, 0)
2765int botan_nist_kw_dec(const char* cipher_algo,
2766 int padded,
2767 const uint8_t wrapped_key[],
2768 size_t wrapped_key_len,
2769 const uint8_t kek[],
2770 size_t kek_len,
2771 uint8_t key[],
2772 size_t* key_len);
2773
2774/**
2775* HOTP
2776*/
2777
2778typedef struct botan_hotp_struct* botan_hotp_t;
2779
2780/**
2781* Initialize a HOTP instance
2782*/
2783BOTAN_FFI_EXPORT(2, 8)
2784int botan_hotp_init(botan_hotp_t* hotp, const uint8_t key[], size_t key_len, const char* hash_algo, size_t digits);
2785
2786/**
2787* Destroy a HOTP instance
2788* @return 0 if success, error if invalid object handle
2789*/
2790BOTAN_FFI_EXPORT(2, 8)
2792
2793/**
2794* Generate a HOTP code for the provided counter
2795*/
2796BOTAN_FFI_EXPORT(2, 8)
2797int botan_hotp_generate(botan_hotp_t hotp, uint32_t* hotp_code, uint64_t hotp_counter);
2798
2799/**
2800* Verify a HOTP code
2801*/
2802BOTAN_FFI_EXPORT(2, 8)
2804 botan_hotp_t hotp, uint64_t* next_hotp_counter, uint32_t hotp_code, uint64_t hotp_counter, size_t resync_range);
2805
2806/**
2807* TOTP
2808*/
2809
2810typedef struct botan_totp_struct* botan_totp_t;
2811
2812/**
2813* Initialize a TOTP instance
2814*/
2815BOTAN_FFI_EXPORT(2, 8)
2816int botan_totp_init(
2817 botan_totp_t* totp, const uint8_t key[], size_t key_len, const char* hash_algo, size_t digits, size_t time_step);
2818
2819/**
2820* Destroy a TOTP instance
2821* @return 0 if success, error if invalid object handle
2822*/
2823BOTAN_FFI_EXPORT(2, 8)
2825
2826/**
2827* Generate a TOTP code for the provided timestamp
2828* @param totp the TOTP object
2829* @param totp_code the OTP code will be written here
2830* @param timestamp the current local timestamp
2831*/
2832BOTAN_FFI_EXPORT(2, 8)
2833int botan_totp_generate(botan_totp_t totp, uint32_t* totp_code, uint64_t timestamp);
2834
2835/**
2836* Verify a TOTP code
2837* @param totp the TOTP object
2838* @param totp_code the presented OTP
2839* @param timestamp the current local timestamp
2840* @param acceptable_clock_drift specifies the acceptable amount
2841* of clock drift (in terms of time steps) between the two hosts.
2842*/
2843BOTAN_FFI_EXPORT(2, 8)
2844int botan_totp_check(botan_totp_t totp, uint32_t totp_code, uint64_t timestamp, size_t acceptable_clock_drift);
2845
2846/**
2847* Format Preserving Encryption
2848*/
2849
2850typedef struct botan_fpe_struct* botan_fpe_t;
2851
2852#define BOTAN_FPE_FLAG_FE1_COMPAT_MODE 1
2853
2854BOTAN_FFI_EXPORT(2, 8)
2856 botan_fpe_t* fpe, botan_mp_t n, const uint8_t key[], size_t key_len, size_t rounds, uint32_t flags);
2857
2858/**
2859* @return 0 if success, error if invalid object handle
2860*/
2861BOTAN_FFI_EXPORT(2, 8)
2863
2864BOTAN_FFI_EXPORT(2, 8)
2865int botan_fpe_encrypt(botan_fpe_t fpe, botan_mp_t x, const uint8_t tweak[], size_t tweak_len);
2866
2867BOTAN_FFI_EXPORT(2, 8)
2868int botan_fpe_decrypt(botan_fpe_t fpe, botan_mp_t x, const uint8_t tweak[], size_t tweak_len);
2869
2870/**
2871* SRP-6 Server Session type
2872*/
2873typedef struct botan_srp6_server_session_struct* botan_srp6_server_session_t;
2874
2875/**
2876* Initialize an SRP-6 server session object
2877* @param srp6 SRP-6 server session object
2878*/
2879BOTAN_FFI_EXPORT(3, 0)
2881
2882/**
2883* Frees all resources of the SRP-6 server session object
2884* @param srp6 SRP-6 server session object
2885* @return 0 if success, error if invalid object handle
2886*/
2887BOTAN_FFI_EXPORT(3, 0)
2889
2890/**
2891* SRP-6 Server side step 1
2892* @param srp6 SRP-6 server session object
2893* @param verifier the verification value saved from client registration
2894* @param verifier_len SRP-6 verifier value length
2895* @param group_id the SRP group id
2896* @param hash_id the SRP hash in use
2897* @param rng_obj a random number generator object
2898* @param B_pub out buffer to store the SRP-6 B value
2899* @param B_pub_len SRP-6 B value length
2900* @return 0 on success, negative on failure
2901*/
2902BOTAN_FFI_EXPORT(3, 0)
2904 const uint8_t verifier[],
2905 size_t verifier_len,
2906 const char* group_id,
2907 const char* hash_id,
2908 botan_rng_t rng_obj,
2909 uint8_t B_pub[],
2910 size_t* B_pub_len);
2911
2912/**
2913* SRP-6 Server side step 2
2914* @param srp6 SRP-6 server session object
2915* @param A the client's value
2916* @param A_len the client's value length
2917* @param key out buffer to store the symmetric key value
2918* @param key_len symmetric key length
2919* @return 0 on success, negative on failure
2920*/
2921BOTAN_FFI_EXPORT(3, 0)
2923 botan_srp6_server_session_t srp6, const uint8_t A[], size_t A_len, uint8_t key[], size_t* key_len);
2924
2925/**
2926* Generate a new SRP-6 verifier
2927* @param identifier a username or other client identifier
2928* @param password the secret used to authenticate user
2929* @param salt a randomly chosen value, at least 128 bits long
2930* @param salt_len the length of salt
2931* @param group_id specifies the shared SRP group
2932* @param hash_id specifies a secure hash function
2933* @param verifier out buffer to store the SRP-6 verifier value
2934* @param verifier_len SRP-6 verifier value length
2935* @return 0 on success, negative on failure
2936*/
2937BOTAN_FFI_EXPORT(3, 0)
2938int botan_srp6_generate_verifier(const char* identifier,
2939 const char* password,
2940 const uint8_t salt[],
2941 size_t salt_len,
2942 const char* group_id,
2943 const char* hash_id,
2944 uint8_t verifier[],
2945 size_t* verifier_len);
2946
2947/**
2948* SRP6a Client side
2949* @param username the username we are attempting login for
2950* @param password the password we are attempting to use
2951* @param group_id specifies the shared SRP group
2952* @param hash_id specifies a secure hash function
2953* @param salt is the salt value sent by the server
2954* @param salt_len the length of salt
2955* @param B is the server's public value
2956* @param B_len is the server's public value length
2957* @param rng_obj is a random number generator object
2958* @param A out buffer to store the SRP-6 A value
2959* @param A_len SRP-6 A verifier value length
2960* @param K out buffer to store the symmetric value
2961* @param K_len symmetric key length
2962* @return 0 on success, negative on failure
2963*/
2964BOTAN_FFI_EXPORT(3, 0)
2965int botan_srp6_client_agree(const char* username,
2966 const char* password,
2967 const char* group_id,
2968 const char* hash_id,
2969 const uint8_t salt[],
2970 size_t salt_len,
2971 const uint8_t B[],
2972 size_t B_len,
2973 botan_rng_t rng_obj,
2974 uint8_t A[],
2975 size_t* A_len,
2976 uint8_t K[],
2977 size_t* K_len);
2978
2979/**
2980* Return the size, in bytes, of the prime associated with group_id
2981*/
2982BOTAN_FFI_EXPORT(3, 0)
2983int botan_srp6_group_size(const char* group_id, size_t* group_p_bytes);
2984
2985/**
2986 * ZFEC
2987 */
2988
2989/**
2990 * Encode some bytes with certain ZFEC parameters.
2991 *
2992 * @param K the number of shares needed for recovery
2993 * @param N the number of shares generated
2994 * @param input the data to FEC
2995 * @param size the length in bytes of input, which must be a multiple of K
2996 *
2997 * @param outputs An out parameter pointing to a fully allocated array of size
2998 * [N][size / K]. For all n in range, an encoded block will be
2999 * written to the memory starting at outputs[n][0].
3000 *
3001 * @return 0 on success, negative on failure
3002 */
3003BOTAN_FFI_EXPORT(3, 0)
3004int botan_zfec_encode(size_t K, size_t N, const uint8_t* input, size_t size, uint8_t** outputs);
3005
3006/**
3007 * Decode some previously encoded shares using certain ZFEC parameters.
3008 *
3009 * @param K the number of shares needed for recovery
3010 * @param N the total number of shares
3011 *
3012 * @param indexes The index into the encoder's outputs for the corresponding
3013 * element of the inputs array. Must be of length K.
3014 *
3015 * @param inputs K previously encoded shares to decode
3016 * @param shareSize the length in bytes of each input
3017 *
3018 * @param outputs An out parameter pointing to a fully allocated array of size
3019 * [K][shareSize]. For all k in range, a decoded block will
3020 * written to the memory starting at outputs[k][0].
3021 *
3022 * @return 0 on success, negative on failure
3023 */
3024BOTAN_FFI_EXPORT(3, 0)
3026 size_t K, size_t N, const size_t* indexes, uint8_t* const* inputs, size_t shareSize, uint8_t** outputs);
3027
3028/**
3029* TPM2 context
3030*/
3031typedef struct botan_tpm2_ctx_struct* botan_tpm2_ctx_t;
3032
3033/**
3034* TPM2 session
3035*/
3036typedef struct botan_tpm2_session_struct* botan_tpm2_session_t;
3037
3038/**
3039* TPM2 crypto backend state object
3040*/
3041typedef struct botan_tpm2_crypto_backend_state_struct* botan_tpm2_crypto_backend_state_t;
3042
3043struct ESYS_CONTEXT;
3044
3045/**
3046* Checks if Botan's TSS2 crypto backend can be used in this build
3047* @returns 1 if the crypto backend can be enabled
3048*/
3049BOTAN_FFI_EXPORT(3, 6)
3051
3052/**
3053* Initialize a TPM2 context
3054* @param ctx_out output TPM2 context
3055* @param tcti_nameconf TCTI config (may be nullptr)
3056* @return 0 on success
3057*/
3058BOTAN_FFI_EXPORT(3, 6) int botan_tpm2_ctx_init(botan_tpm2_ctx_t* ctx_out, const char* tcti_nameconf);
3059
3060/**
3061* Initialize a TPM2 context
3062* @param ctx_out output TPM2 context
3063* @param tcti_name TCTI name (may be nullptr)
3064* @param tcti_conf TCTI config (may be nullptr)
3065* @return 0 on success
3066*/
3067BOTAN_FFI_EXPORT(3, 6)
3068int botan_tpm2_ctx_init_ex(botan_tpm2_ctx_t* ctx_out, const char* tcti_name, const char* tcti_conf);
3069
3070/**
3071* Wrap an existing ESYS_CONTEXT for use in Botan.
3072* Note that destroying the created botan_tpm2_ctx_t won't
3073* finalize @p esys_ctx
3074* @param ctx_out output TPM2 context
3075* @param esys_ctx ESYS_CONTEXT to wrap
3076* @return 0 on success
3077*/
3078BOTAN_FFI_EXPORT(3, 7)
3079int botan_tpm2_ctx_from_esys(botan_tpm2_ctx_t* ctx_out, struct ESYS_CONTEXT* esys_ctx);
3080
3081/**
3082* Enable Botan's TSS2 crypto backend that replaces the cryptographic functions
3083* required for the communication with the TPM with implementations provided
3084* by Botan instead of using TSS' defaults OpenSSL or mbedTLS.
3085* Note that the provided @p rng should not be dependent on the TPM and the
3086* caller must ensure that it remains usable for the lifetime of the @p ctx.
3087* @param ctx TPM2 context
3088* @param rng random number generator to be used by the crypto backend
3089*/
3090BOTAN_FFI_EXPORT(3, 6)
3092
3093/**
3094* Frees all resources of a TPM2 context
3095* @param ctx TPM2 context
3096* @return 0 on success
3097*/
3099
3100/**
3101* Use this if you just need Botan's crypto backend but do not want to wrap any
3102* other ESYS functionality using Botan's TPM2 wrapper.
3103* A Crypto Backend State is created that the user needs to keep alive for as
3104* long as the crypto backend is used and needs to be destroyed after.
3105* Note that the provided @p rng should not be dependent on the TPM and the
3106* caller must ensure that it remains usable for the lifetime of the @p esys_ctx.
3107* @param cbs_out To be created Crypto Backend State
3108* @param esys_ctx TPM2 context
3109* @param rng random number generator to be used by the crypto backend
3110*/
3111BOTAN_FFI_EXPORT(3, 7)
3113 struct ESYS_CONTEXT* esys_ctx,
3114 botan_rng_t rng);
3115
3116/**
3117* Frees all resources of a TPM2 Crypto Callback State
3118* Note that this does not attempt to de-register the crypto backend,
3119* it just frees the resource pointed to by @p cbs. Use the ESAPI function
3120* ``Esys_SetCryptoCallbacks(ctx, nullptr)`` to deregister manually.
3121* @param cbs TPM2 Crypto Callback State
3122* @return 0 on success
3123*/
3125
3126/**
3127* Initialize a random number generator object via TPM2
3128* @param rng_out rng object to create
3129* @param ctx TPM2 context
3130* @param s1 the first session to use (optional, may be nullptr)
3131* @param s2 the second session to use (optional, may be nullptr)
3132* @param s3 the third session to use (optional, may be nullptr)
3133*/
3134BOTAN_FFI_EXPORT(3, 6)
3135int botan_tpm2_rng_init(botan_rng_t* rng_out,
3136 botan_tpm2_ctx_t ctx,
3140
3141/**
3142* Create an unauthenticated session for use with TPM2
3143* @param session_out the session object to create
3144* @param ctx TPM2 context
3145*/
3146BOTAN_FFI_EXPORT(3, 6)
3148
3149/**
3150* Create an unauthenticated session for use with TPM2
3151* @param session the session object to destroy
3152*/
3153BOTAN_FFI_EXPORT(3, 6)
3155
3156/* NOLINTEND(*-macro-usage,*-misplaced-const) */
3157
3158#ifdef __cplusplus
3159}
3160#endif
3161
3162#endif
uint32_t botan_version_datestamp()
Definition ffi.cpp:309
int botan_same_mem(const uint8_t *x, const uint8_t *y, size_t len)
Definition ffi.cpp:319
const char * botan_version_string()
Definition ffi.cpp:293
int botan_base64_decode(const char *base64_str, size_t in_len, uint8_t *out, size_t *out_len)
Definition ffi.cpp:350
uint32_t botan_version_patch()
Definition ffi.cpp:305
int botan_base64_encode(const uint8_t *in, size_t len, char *out, size_t *out_len)
Definition ffi.cpp:343
int botan_scrub_mem(void *mem, size_t bytes)
Definition ffi.cpp:323
int botan_hex_encode(const uint8_t *in, size_t len, char *out, uint32_t flags)
Definition ffi.cpp:328
uint32_t botan_version_major()
Definition ffi.cpp:297
uint32_t botan_ffi_api_version()
Definition ffi.cpp:219
int botan_ffi_supports_api(uint32_t api_version)
Definition ffi.cpp:223
const char * botan_error_description(int err)
Definition ffi.cpp:142
uint32_t botan_version_minor()
Definition ffi.cpp:301
int botan_constant_time_compare(const uint8_t *x, const uint8_t *y, size_t len)
Definition ffi.cpp:313
int botan_hex_decode(const char *hex_str, size_t in_len, uint8_t *out, size_t *out_len)
Definition ffi.cpp:336
const char * botan_error_last_exception_message()
Definition ffi.cpp:138
int botan_mp_lshift(botan_mp_t out, botan_mp_t in, size_t shift)
Definition ffi_mp.cpp:232
int botan_block_cipher_get_keyspec(botan_block_cipher_t cipher, size_t *out_minimum_keylength, size_t *out_maximum_keylength, size_t *out_keylength_modulo)
Definition ffi_block.cpp:86
int botan_block_cipher_init(botan_block_cipher_t *bc, const char *cipher_name)
Definition ffi_block.cpp:18
int botan_pk_op_sign_finish(botan_pk_op_sign_t op, botan_rng_t rng, uint8_t sig[], size_t *sig_len)
int botan_x509_cert_get_subject_dn_count(botan_x509_cert_t cert, const char *key, size_t *count)
Definition ffi_cert.cpp:525
int botan_x509_is_revoked(botan_x509_crl_t crl, botan_x509_cert_t cert)
int botan_mp_is_prime(botan_mp_t n, botan_rng_t rng, size_t test_prob)
Definition ffi_mp.cpp:266
int botan_rng_reseed_from_rng(botan_rng_t rng, botan_rng_t source_rng, size_t bits)
Definition ffi_rng.cpp:182
int botan_x509_crl_destroy(botan_x509_crl_t crl)
int botan_privkey_load_x448(botan_privkey_t *key, const uint8_t privkey[56])
int botan_ec_group_get_g_x(botan_mp_t *g_x, botan_ec_group_t ec_group)
Definition ffi_ec.cpp:174
int botan_mp_div(botan_mp_t quotient, botan_mp_t remainder, botan_mp_t x, botan_mp_t y)
Definition ffi_mp.cpp:194
int botan_mp_set_from_int(botan_mp_t mp, int initial_value)
Definition ffi_mp.cpp:39
int botan_mp_to_bin(botan_mp_t mp, uint8_t vec[])
Definition ffi_mp.cpp:122
int botan_x509_cert_destroy(botan_x509_cert_t cert)
Definition ffi_cert.cpp:593
int botan_pubkey_load_ml_dsa(botan_pubkey_t *key, const uint8_t pubkey[], size_t key_len, const char *mldsa_mode)
int botan_bcrypt_generate(uint8_t *out, size_t *out_len, const char *password, botan_rng_t rng, size_t work_factor, uint32_t flags)
Definition ffi_kdf.cpp:157
int botan_pk_op_sign_output_length(botan_pk_op_sign_t op, size_t *olen)
struct botan_pk_op_kem_decrypt_struct * botan_pk_op_kem_decrypt_t
Definition ffi.h:2167
int botan_x509_cert_view_string_values(botan_x509_cert_t cert, botan_x509_value_type value_type, size_t index, botan_view_ctx ctx, botan_view_str_fn view)
Definition ffi_cert.cpp:345
int botan_x509_crl_entry_serial_number(botan_x509_crl_entry_t entry, botan_mp_t *serial_number)
int botan_privkey_check_key(botan_privkey_t key, botan_rng_t rng, uint32_t flags)
Definition ffi_pkey.cpp:160
int botan_xof_clear(botan_xof_t xof)
Definition ffi_xof.cpp:62
int botan_mp_rand_range(botan_mp_t rand_out, botan_rng_t rng, botan_mp_t lower_bound, botan_mp_t upper_bound)
Definition ffi_mp.cpp:257
int botan_pk_op_decrypt(botan_pk_op_decrypt_t op, uint8_t out[], size_t *out_len, const uint8_t ciphertext[], size_t ciphertext_len)
int botan_srp6_server_session_step1(botan_srp6_server_session_t srp6, const uint8_t verifier[], size_t verifier_len, const char *group_id, const char *hash_id, botan_rng_t rng_obj, uint8_t B_pub[], size_t *B_pub_len)
int botan_privkey_rsa_get_q(botan_mp_t q, botan_privkey_t rsa_key)
int botan_hash_update(botan_hash_t hash, const uint8_t *in, size_t in_len)
Definition ffi_hash.cpp:59
int botan_pubkey_load_ecdh(botan_pubkey_t *key, botan_mp_t public_x, botan_mp_t public_y, const char *curve_name)
int botan_mp_rshift(botan_mp_t out, botan_mp_t in, size_t shift)
Definition ffi_mp.cpp:236
int botan_nist_kw_enc(const char *cipher_algo, int padded, const uint8_t key[], size_t key_len, const uint8_t kek[], size_t kek_len, uint8_t wrapped_key[], size_t *wrapped_key_len)
int botan_privkey_create_rsa(botan_privkey_t *key, botan_rng_t rng, size_t n_bits)
int botan_privkey_view_kyber_raw_key(botan_privkey_t key, botan_view_ctx ctx, botan_view_bin_fn view)
int botan_privkey_create_ecdsa(botan_privkey_t *key, botan_rng_t rng, const char *params)
struct botan_pubkey_struct * botan_pubkey_t
Definition ffi.h:1650
int botan_mp_set_from_radix_str(botan_mp_t dest, const char *str, size_t radix)
Definition ffi_mp.cpp:47
int botan_rng_add_entropy(botan_rng_t rng, const uint8_t *entropy, size_t entropy_len)
Definition ffi_rng.cpp:178
int botan_key_unwrap3394(const uint8_t wrapped_key[], size_t wrapped_key_len, const uint8_t kek[], size_t kek_len, uint8_t key[], size_t *key_len)
int botan_cipher_start(botan_cipher_t cipher, const uint8_t *nonce, size_t nonce_len)
int botan_mp_add(botan_mp_t result, botan_mp_t x, botan_mp_t y)
Definition ffi_mp.cpp:144
int botan_oid_cmp(int *result, botan_asn1_oid_t a, botan_asn1_oid_t b)
Definition ffi_oid.cpp:63
int botan_mp_powmod(botan_mp_t out, botan_mp_t base, botan_mp_t exponent, botan_mp_t modulus)
Definition ffi_mp.cpp:227
int botan_x509_crl_next_update(botan_x509_crl_t crl, uint64_t *time_since_epoch)
int botan_cipher_valid_nonce_length(botan_cipher_t cipher, size_t nl)
int botan_ec_group_view_pem(botan_ec_group_t ec_group, botan_view_ctx ctx, botan_view_str_fn view)
Definition ffi_ec.cpp:132
int botan_mac_init(botan_mac_t *mac, const char *mac_name, uint32_t flags)
Definition ffi_mac.cpp:18
int botan_ec_group_get_curve_oid(botan_asn1_oid_t *oid, botan_ec_group_t ec_group)
Definition ffi_ec.cpp:138
int botan_srp6_server_session_step2(botan_srp6_server_session_t srp6, const uint8_t A[], size_t A_len, uint8_t key[], size_t *key_len)
Definition ffi_srp6.cpp:99
int botan_mp_to_uint32(botan_mp_t mp, uint32_t *val)
Definition ffi_mp.cpp:133
int botan_pubkey_estimated_strength(botan_pubkey_t key, size_t *estimate)
Definition ffi_pkey.cpp:434
int botan_mceies_encrypt(botan_pubkey_t mce_key, botan_rng_t rng, const char *aead, const uint8_t pt[], size_t pt_len, const uint8_t ad[], size_t ad_len, uint8_t ct[], size_t *ct_len)
int botan_pkcs_hash_id(const char *hash_name, uint8_t pkcs_id[], size_t *pkcs_id_len)
Definition ffi_pkey.cpp:445
int botan_privkey_rsa_get_privkey(botan_privkey_t rsa_key, uint8_t out[], size_t *out_len, uint32_t flags)
int botan_privkey_create_dh(botan_privkey_t *key, botan_rng_t rng, const char *param)
int botan_privkey_load_rsa_pkcs1(botan_privkey_t *key, const uint8_t bits[], size_t len)
int botan_hash_name(botan_hash_t hash, char *name, size_t *name_len)
Definition ffi_hash.cpp:83
int botan_x509_cert_get_issuer_dn_count(botan_x509_cert_t cert, const char *key, size_t *count)
Definition ffi_cert.cpp:491
int botan_cipher_get_tag_length(botan_cipher_t cipher, size_t *tag_size)
int botan_ec_group_from_params(botan_ec_group_t *ec_group, botan_asn1_oid_t oid, botan_mp_t p, botan_mp_t a, botan_mp_t b, botan_mp_t base_x, botan_mp_t base_y, botan_mp_t order)
Definition ffi_ec.cpp:50
int botan_pubkey_load_slh_dsa(botan_pubkey_t *key, const uint8_t pubkey[], size_t key_len, const char *slhdsa_mode)
int botan_ec_group_get_g_y(botan_mp_t *g_y, botan_ec_group_t ec_group)
Definition ffi_ec.cpp:179
int botan_pk_op_key_agreement_export_public(botan_privkey_t key, uint8_t out[], size_t *out_len)
int botan_x509_crl_entry_destroy(botan_x509_crl_entry_t entry)
int botan_x509_cert_issuer_alternative_names_count(botan_x509_cert_t cert, size_t *count)
Definition ffi_cert.cpp:923
int botan_privkey_get_field(botan_mp_t output, botan_privkey_t key, const char *field_name)
int botan_x509_cert_view_binary_values(botan_x509_cert_t cert, botan_x509_value_type value_type, size_t index, botan_view_ctx ctx, botan_view_bin_fn view)
Definition ffi_cert.cpp:278
int botan_x509_crl_view_binary_values_count(botan_x509_crl_t crl_obj, botan_x509_value_type value_type, size_t *count)
int botan_srp6_generate_verifier(const char *identifier, const char *password, const uint8_t salt[], size_t salt_len, const char *group_id, const char *hash_id, uint8_t verifier[], size_t *verifier_len)
Definition ffi_srp6.cpp:120
int botan_rng_init_custom(botan_rng_t *rng_out, const char *rng_name, void *context, int(*get_cb)(void *context, uint8_t *out, size_t out_len), int(*add_entropy_cb)(void *context, const uint8_t input[], size_t length), void(*destroy_cb)(void *context))
Definition ffi_rng.cpp:76
int botan_hotp_generate(botan_hotp_t hotp, uint32_t *hotp_code, uint64_t hotp_counter)
Definition ffi_hotp.cpp:53
#define BOTAN_FFI_EXPORT(maj, min)
Definition ffi.h:91
int botan_pwdhash_timed(const char *algo, uint32_t msec, size_t *param1, size_t *param2, size_t *param3, uint8_t out[], size_t out_len, const char *passphrase, size_t passphrase_len, const uint8_t salt[], size_t salt_len)
Definition ffi_kdf.cpp:86
struct botan_srp6_server_session_struct * botan_srp6_server_session_t
Definition ffi.h:2873
int botan_rng_reseed(botan_rng_t rng, size_t bits)
Definition ffi_rng.cpp:174
int botan_mp_init(botan_mp_t *mp)
Definition ffi_mp.cpp:24
int botan_tpm2_ctx_enable_crypto_backend(botan_tpm2_ctx_t ctx, botan_rng_t rng)
Definition ffi_tpm2.cpp:150
int botan_privkey_view_encrypted_pem_timed(botan_privkey_t key, botan_rng_t rng, const char *passphrase, const char *cipher_algo, const char *pbkdf_algo, size_t pbkdf_runtime_msec, botan_view_ctx ctx, botan_view_str_fn view)
Definition ffi_pkey.cpp:282
int botan_tpm2_ctx_init_ex(botan_tpm2_ctx_t *ctx_out, const char *tcti_name, const char *tcti_conf)
Definition ffi_tpm2.cpp:100
int botan_pk_op_decrypt_create(botan_pk_op_decrypt_t *op, botan_privkey_t key, const char *padding, uint32_t flags)
Definition ffi_pk_op.cpp:70
int botan_pubkey_load_classic_mceliece(botan_pubkey_t *key, const uint8_t pubkey[], size_t key_len, const char *cmce_mode)
int botan_x509_general_name_view_binary_value(botan_x509_general_name_t name, botan_view_ctx ctx, botan_view_bin_fn view)
Definition ffi_cert.cpp:758
int botan_pubkey_rsa_get_n(botan_mp_t n, botan_pubkey_t rsa_key)
int botan_privkey_load(botan_privkey_t *key, botan_rng_t rng, const uint8_t bits[], size_t len, const char *password)
Definition ffi_pkey.cpp:87
int botan_totp_generate(botan_totp_t totp, uint32_t *totp_code, uint64_t timestamp)
Definition ffi_totp.cpp:54
struct botan_pk_op_decrypt_struct * botan_pk_op_decrypt_t
Definition ffi.h:2046
struct botan_mac_struct * botan_mac_t
Definition ffi.h:541
int botan_mp_to_str(botan_mp_t mp, uint8_t radix, char *out, size_t *out_len)
Definition ffi_mp.cpp:98
int botan_x509_crl_this_update(botan_x509_crl_t crl, uint64_t *time_since_epoch)
int botan_x509_cert_view_binary_values_count(botan_x509_cert_t cert, botan_x509_value_type value_type, size_t *count)
Definition ffi_cert.cpp:333
int botan_zfec_decode(size_t K, size_t N, const size_t *indexes, uint8_t *const *inputs, size_t shareSize, uint8_t **outputs)
Definition ffi_zfec.cpp:32
int botan_mac_destroy(botan_mac_t mac)
Definition ffi_mac.cpp:36
int botan_mp_is_odd(botan_mp_t mp)
Definition ffi_mp.cpp:210
struct botan_asn1_oid_struct * botan_asn1_oid_t
Definition ffi.h:1224
int botan_totp_init(botan_totp_t *totp, const uint8_t key[], size_t key_len, const char *hash_algo, size_t digits, size_t time_step)
Definition ffi_totp.cpp:26
int botan_x509_cert_get_public_key(botan_x509_cert_t cert, botan_pubkey_t *key)
Definition ffi_cert.cpp:455
int botan_cipher_requires_entire_message(botan_cipher_t cipher)
int botan_tpm2_enable_crypto_backend(botan_tpm2_crypto_backend_state_t *cbs_out, struct ESYS_CONTEXT *esys_ctx, botan_rng_t rng)
Definition ffi_tpm2.cpp:181
int botan_privkey_load_classic_mceliece(botan_privkey_t *key, const uint8_t privkey[], size_t key_len, const char *cmce_mode)
int botan_privkey_load_x25519(botan_privkey_t *key, const uint8_t privkey[32])
struct botan_privkey_struct * botan_privkey_t
Definition ffi.h:1417
int botan_cipher_output_length(botan_cipher_t cipher, size_t in_len, size_t *out_len)
int botan_oid_from_string(botan_asn1_oid_t *oid, const char *oid_str)
Definition ffi_oid.cpp:22
struct botan_x509_crl_entry_struct * botan_x509_crl_entry_t
Definition ffi.h:2546
int botan_x509_cert_allowed_extended_usage_oid(botan_x509_cert_t cert, botan_asn1_oid_t oid)
Definition ffi_cert.cpp:584
int botan_cipher_reset(botan_cipher_t cipher)
int botan_cipher_init(botan_cipher_t *cipher, const char *name, uint32_t flags)
int botan_privkey_view_encrypted_der(botan_privkey_t key, botan_rng_t rng, const char *passphrase, const char *cipher_algo, const char *pbkdf_algo, size_t pbkdf_iterations, botan_view_ctx ctx, botan_view_bin_fn view)
Definition ffi_pkey.cpp:328
int botan_block_cipher_clear(botan_block_cipher_t bc)
Definition ffi_block.cpp:42
int botan_pubkey_fingerprint(botan_pubkey_t key, const char *hash, uint8_t out[], size_t *out_len)
Definition ffi_pkey.cpp:438
int botan_xof_block_size(botan_xof_t xof, size_t *block_size)
Definition ffi_xof.cpp:43
int botan_pubkey_dsa_get_p(botan_mp_t p, botan_pubkey_t key)
int botan_privkey_export(botan_privkey_t key, uint8_t out[], size_t *out_len, uint32_t flags)
Definition ffi_pkey.cpp:194
int botan_hash_destroy(botan_hash_t hash)
Definition ffi_hash.cpp:37
int botan_pubkey_load_ecdh_sec1(botan_pubkey_t *key, const uint8_t sec1[], size_t sec1_len, const char *curve_name)
int botan_pk_op_kem_encrypt_shared_key_length(botan_pk_op_kem_encrypt_t op, size_t desired_shared_key_length, size_t *output_shared_key_length)
int botan_pk_op_key_agreement_size(botan_pk_op_ka_t op, size_t *out_len)
int botan_x509_cert_load_file(botan_x509_cert_t *cert_obj, const char *filename)
Definition ffi_cert.cpp:169
int botan_pk_op_sign_update(botan_pk_op_sign_t op, const uint8_t in[], size_t in_len)
int botan_mac_set_nonce(botan_mac_t mac, const uint8_t *nonce, size_t nonce_len)
Definition ffi_mac.cpp:44
const char * botan_x509_cert_validation_status(int code)
int botan_pubkey_ecc_key_used_explicit_encoding(botan_pubkey_t key)
int botan_block_cipher_block_size(botan_block_cipher_t bc)
Definition ffi_block.cpp:60
int botan_pubkey_load_frodokem(botan_pubkey_t *key, const uint8_t pubkey[], size_t key_len, const char *frodo_mode)
int botan_x509_crl_update(botan_x509_crl_t *crl_obj, botan_x509_crl_t last_crl, botan_rng_t rng, botan_x509_cert_t ca_cert, botan_privkey_t ca_key, uint64_t issue_time, uint32_t next_update, const botan_x509_crl_entry_t *new_entries, size_t new_entries_len, const char *hash_fn, const char *padding)
int botan_privkey_ed25519_get_privkey(botan_privkey_t key, uint8_t output[64])
struct botan_x509_crl_struct * botan_x509_crl_t
Definition ffi.h:2545
int botan_srp6_server_session_init(botan_srp6_server_session_t *srp6)
Definition ffi_srp6.cpp:32
struct botan_tpm2_session_struct * botan_tpm2_session_t
Definition ffi.h:3036
int botan_privkey_export_pubkey(botan_pubkey_t *out, botan_privkey_t in)
Definition ffi_pkey.cpp:136
int botan_tpm2_ctx_init(botan_tpm2_ctx_t *ctx_out, const char *tcti_nameconf)
Definition ffi_tpm2.cpp:75
int botan_cipher_destroy(botan_cipher_t cipher)
int botan_x509_cert_verify_with_crl(int *validation_result, botan_x509_cert_t cert, const botan_x509_cert_t *intermediates, size_t intermediates_len, const botan_x509_cert_t *trusted, size_t trusted_len, const botan_x509_crl_t *crls, size_t crls_len, const char *trusted_path, size_t required_strength, const char *hostname, uint64_t reference_time)
#define BOTAN_FFI_DEPRECATED(msg)
Definition ffi.h:106
int botan_pubkey_load_rsa_pkcs1(botan_pubkey_t *key, const uint8_t bits[], size_t len)
int botan_mp_num_bytes(botan_mp_t n, size_t *bytes)
Definition ffi_mp.cpp:286
int botan_x509_cert_get_authority_key_id(botan_x509_cert_t cert, uint8_t out[], size_t *out_len)
Definition ffi_cert.cpp:678
int botan_x509_cert_get_issuer_dn(botan_x509_cert_t cert, const char *key, size_t index, uint8_t out[], size_t *out_len)
Definition ffi_cert.cpp:473
int botan_x509_general_name_destroy(botan_x509_general_name_t alt_names)
Definition ffi_cert.cpp:780
int botan_pubkey_oid(botan_asn1_oid_t *oid, botan_pubkey_t key)
Definition ffi_pkey.cpp:378
int botan_x509_cert_subject_alternative_names_count(botan_x509_cert_t cert, size_t *count)
Definition ffi_cert.cpp:884
int botan_pk_op_decrypt_destroy(botan_pk_op_decrypt_t op)
Definition ffi_pk_op.cpp:90
botan_x509_crl_reason_code
Definition ffi.h:2577
@ BOTAN_CRL_ENTRY_PRIVILEGE_WITHDRAWN
Definition ffi.h:2586
@ BOTAN_CRL_ENTRY_UNSPECIFIED
Definition ffi.h:2578
@ BOTAN_CRL_ENTRY_SUPERSEDED
Definition ffi.h:2582
@ BOTAN_CRL_ENTRY_CERTIFICATE_HOLD
Definition ffi.h:2584
@ BOTAN_CRL_ENTRY_CESSATION_OF_OPERATION
Definition ffi.h:2583
@ BOTAN_CRL_ENTRY_CA_COMPROMISE
Definition ffi.h:2580
@ BOTAN_CRL_ENTRY_REMOVE_FROM_CRL
Definition ffi.h:2585
@ BOTAN_CRL_ENTRY_AA_COMPROMISE
Definition ffi.h:2587
@ BOTAN_CRL_ENTRY_KEY_COMPROMISE
Definition ffi.h:2579
@ BOTAN_CRL_ENTRY_AFFILIATION_CHANGED
Definition ffi.h:2581
int botan_x509_cert_excluded_name_constraints(botan_x509_cert_t cert, size_t index, botan_x509_general_name_t *constraint)
Definition ffi_cert.cpp:824
int botan_cipher_name(botan_cipher_t cipher, char *name, size_t *name_len)
int botan_cipher_set_associated_data(botan_cipher_t cipher, const uint8_t *ad, size_t ad_len)
int botan_mp_view_hex(botan_mp_t mp, botan_view_ctx ctx, botan_view_str_fn view)
Definition ffi_mp.cpp:91
int botan_x509_crl_entries_count(botan_x509_crl_t crl, size_t *count)
int botan_privkey_load_rsa(botan_privkey_t *key, botan_mp_t p, botan_mp_t q, botan_mp_t e)
int botan_privkey_destroy(botan_privkey_t key)
Definition ffi_pkey.cpp:112
int botan_pubkey_algo_name(botan_pubkey_t key, char out[], size_t *out_len)
Definition ffi_pkey.cpp:148
struct botan_pk_op_encrypt_struct * botan_pk_op_encrypt_t
Definition ffi.h:2022
int botan_pubkey_view_pem(botan_pubkey_t key, botan_view_ctx ctx, botan_view_str_fn view)
Definition ffi_pkey.cpp:184
int botan_mp_from_bin(botan_mp_t mp, const uint8_t vec[], size_t vec_len)
Definition ffi_mp.cpp:76
int botan_ec_group_get_a(botan_mp_t *a, botan_ec_group_t ec_group)
Definition ffi_ec.cpp:166
int botan_block_cipher_decrypt_blocks(botan_block_cipher_t bc, const uint8_t in[], uint8_t out[], size_t blocks)
Definition ffi_block.cpp:71
int botan_hash_clear(botan_hash_t hash)
Definition ffi_hash.cpp:55
int botan_x509_crl_entries(botan_x509_crl_t crl, size_t index, botan_x509_crl_entry_t *entry)
int botan_pubkey_dsa_get_y(botan_mp_t y, botan_pubkey_t key)
int botan_mp_add_u32(botan_mp_t result, botan_mp_t x, uint32_t y)
Definition ffi_mp.cpp:164
int botan_pubkey_load_ml_kem(botan_pubkey_t *key, const uint8_t pubkey[], size_t key_len, const char *mlkem_mode)
int botan_mp_to_hex(botan_mp_t mp, char *out)
Definition ffi_mp.cpp:80
int botan_privkey_view_der(botan_privkey_t key, botan_view_ctx ctx, botan_view_bin_fn view)
Definition ffi_pkey.cpp:206
int botan_privkey_stateful_operation(botan_privkey_t key, int *out)
Definition ffi_pkey.cpp:404
int botan_srp6_client_agree(const char *username, const char *password, const char *group_id, const char *hash_id, const uint8_t salt[], size_t salt_len, const uint8_t B[], size_t B_len, botan_rng_t rng_obj, uint8_t A[], size_t *A_len, uint8_t K[], size_t *K_len)
Definition ffi_srp6.cpp:150
int botan_x509_cert_subject_alternative_names(botan_x509_cert_t cert, size_t index, botan_x509_general_name_t *alt_name)
Definition ffi_cert.cpp:859
int botan_mp_swap(botan_mp_t x, botan_mp_t y)
Definition ffi_mp.cpp:222
struct botan_totp_struct * botan_totp_t
Definition ffi.h:2810
int botan_fpe_decrypt(botan_fpe_t fpe, botan_mp_t x, const uint8_t tweak[], size_t tweak_len)
Definition ffi_fpe.cpp:78
int botan_privkey_load_ed448(botan_privkey_t *key, const uint8_t privkey[57])
int botan_mp_destroy(botan_mp_t mp)
Definition ffi_mp.cpp:140
int botan_mp_mod_mul(botan_mp_t result, botan_mp_t x, botan_mp_t y, botan_mp_t mod)
Definition ffi_mp.cpp:246
int botan_pk_op_encrypt(botan_pk_op_encrypt_t op, botan_rng_t rng, uint8_t out[], size_t *out_len, const uint8_t plaintext[], size_t plaintext_len)
Definition ffi_pk_op.cpp:56
int botan_x509_crl_entry_revocation_date(botan_x509_crl_entry_t entry, uint64_t *time_since_epoch)
int botan_x509_cert_issuer_alternative_names(botan_x509_cert_t cert, size_t index, botan_x509_general_name_t *alt_name)
Definition ffi_cert.cpp:898
int botan_privkey_view_raw(botan_privkey_t key, botan_view_ctx ctx, botan_view_bin_fn view)
Definition ffi_pkey.cpp:216
int botan_privkey_load_dh(botan_privkey_t *key, botan_mp_t p, botan_mp_t g, botan_mp_t x)
int botan_hash_output_length(botan_hash_t hash, size_t *output_length)
Definition ffi_hash.cpp:41
struct botan_x509_general_name_struct * botan_x509_general_name_t
Definition ffi.h:2414
int botan_ec_group_equal(botan_ec_group_t curve1, botan_ec_group_t curve2)
Definition ffi_ec.cpp:189
int botan_pubkey_load_ed25519(botan_pubkey_t *key, const uint8_t pubkey[32])
int botan_mp_rand_bits(botan_mp_t rand_out, botan_rng_t rng, size_t bits)
Definition ffi_mp.cpp:253
int botan_tpm2_rng_init(botan_rng_t *rng_out, botan_tpm2_ctx_t ctx, botan_tpm2_session_t s1, botan_tpm2_session_t s2, botan_tpm2_session_t s3)
Definition ffi_tpm2.cpp:212
int botan_pubkey_view_ec_public_point(botan_pubkey_t key, botan_view_ctx ctx, botan_view_bin_fn view)
int botan_x509_cert_serial_number(botan_x509_cert_t cert, botan_mp_t *serial_number)
Definition ffi_cert.cpp:649
int botan_pk_op_kem_decrypt_shared_key(botan_pk_op_kem_decrypt_t op, const uint8_t salt[], size_t salt_len, const uint8_t encapsulated_key[], size_t encapsulated_key_len, size_t desired_shared_key_len, uint8_t shared_key[], size_t *shared_key_len)
int botan_pubkey_load_sm2_sec1(botan_pubkey_t *key, const uint8_t sec1[], size_t sec1_len, const char *curve_name)
int botan_cipher_set_key(botan_cipher_t cipher, const uint8_t *key, size_t key_len)
int botan_x509_cert_get_time_expires(botan_x509_cert_t cert, char out[], size_t *out_len)
Definition ffi_cert.cpp:612
int botan_mp_equal(botan_mp_t x, botan_mp_t y)
Definition ffi_mp.cpp:202
int botan_privkey_export_encrypted_pbkdf_iter(botan_privkey_t key, uint8_t out[], size_t *out_len, botan_rng_t rng, const char *passphrase, size_t pbkdf_iterations, const char *cipher_algo, const char *pbkdf_algo, uint32_t flags)
Definition ffi_pkey.cpp:308
int botan_srp6_server_session_destroy(botan_srp6_server_session_t srp6)
Definition ffi_srp6.cpp:42
int botan_privkey_rsa_get_n(botan_mp_t n, botan_privkey_t rsa_key)
int botan_ec_group_view_der(botan_ec_group_t ec_group, botan_view_ctx ctx, botan_view_bin_fn view)
Definition ffi_ec.cpp:127
int botan_totp_destroy(botan_totp_t totp)
Definition ffi_totp.cpp:45
int botan_pk_op_key_agreement_create(botan_pk_op_ka_t *op, botan_privkey_t key, const char *kdf, uint32_t flags)
int botan_oid_register(botan_asn1_oid_t oid, const char *name)
Definition ffi_oid.cpp:40
int botan_pk_op_key_agreement_destroy(botan_pk_op_ka_t op)
int botan_mp_set_from_str(botan_mp_t dest, const char *str)
Definition ffi_mp.cpp:43
int botan_privkey_view_encrypted_der_timed(botan_privkey_t key, botan_rng_t rng, const char *passphrase, const char *cipher_algo, const char *pbkdf_algo, size_t pbkdf_runtime_msec, botan_view_ctx ctx, botan_view_bin_fn view)
Definition ffi_pkey.cpp:256
int botan_mp_flip_sign(botan_mp_t mp)
Definition ffi_mp.cpp:72
int botan_xof_name(botan_xof_t xof, char *name, size_t *name_len)
Definition ffi_xof.cpp:50
int botan_scrypt(uint8_t out[], size_t out_len, const char *passphrase, const uint8_t salt[], size_t salt_len, size_t N, size_t r, size_t p)
Definition ffi_kdf.cpp:146
int botan_pubkey_view_der(botan_pubkey_t key, botan_view_ctx ctx, botan_view_bin_fn view)
Definition ffi_pkey.cpp:179
int botan_privkey_remaining_operations(botan_privkey_t key, uint64_t *out)
Definition ffi_pkey.cpp:419
int botan_cipher_get_ideal_update_granularity(botan_cipher_t cipher, size_t *ug)
int botan_mp_clear_bit(botan_mp_t n, size_t bit)
Definition ffi_mp.cpp:278
int botan_pk_op_verify_update(botan_pk_op_verify_t op, const uint8_t in[], size_t in_len)
int botan_mceies_decrypt(botan_privkey_t mce_key, const char *aead, const uint8_t ct[], size_t ct_len, const uint8_t ad[], size_t ad_len, uint8_t pt[], size_t *pt_len)
int botan_x509_cert_permitted_name_constraints(botan_x509_cert_t cert, size_t index, botan_x509_general_name_t *constraint)
Definition ffi_cert.cpp:789
struct botan_pk_op_kem_encrypt_struct * botan_pk_op_kem_encrypt_t
Definition ffi.h:2137
int botan_xof_output(botan_xof_t xof, uint8_t *out, size_t out_len)
Definition ffi_xof.cpp:78
int botan_x509_cert_view_as_string(botan_x509_cert_t cert, botan_view_ctx ctx, botan_view_str_fn view)
Definition ffi_cert.cpp:545
int botan_pubkey_x448_get_pubkey(botan_pubkey_t key, uint8_t pubkey[56])
int botan_mp_is_zero(botan_mp_t mp)
Definition ffi_mp.cpp:206
int botan_mp_mod_inverse(botan_mp_t out, botan_mp_t in, botan_mp_t modulus)
Definition ffi_mp.cpp:240
int botan_mp_cmp(int *result, botan_mp_t x, botan_mp_t y)
Definition ffi_mp.cpp:218
int botan_x509_cert_get_time_starts(botan_x509_cert_t cert, char out[], size_t *out_len)
Definition ffi_cert.cpp:602
int botan_pk_op_kem_decrypt_create(botan_pk_op_kem_decrypt_t *op, botan_privkey_t key, const char *kdf)
int botan_pubkey_export(botan_pubkey_t key, uint8_t out[], size_t *out_len, uint32_t flags)
Definition ffi_pkey.cpp:167
int botan_xof_init(botan_xof_t *xof, const char *xof_name, uint32_t flags)
Definition ffi_xof.cpp:19
int botan_privkey_load_slh_dsa(botan_privkey_t *key, const uint8_t privkey[], size_t key_len, const char *slhdsa_mode)
struct botan_hotp_struct * botan_hotp_t
Definition ffi.h:2778
int botan_pbkdf(const char *pbkdf_algo, uint8_t out[], size_t out_len, const char *passphrase, const uint8_t salt[], size_t salt_len, size_t iterations)
Definition ffi_kdf.cpp:22
int botan_pubkey_rsa_get_e(botan_mp_t e, botan_pubkey_t rsa_key)
int botan_mp_gcd(botan_mp_t out, botan_mp_t x, botan_mp_t y)
Definition ffi_mp.cpp:262
struct botan_block_cipher_struct * botan_block_cipher_t
Definition ffi.h:937
struct botan_ec_group_struct * botan_ec_group_t
Definition ffi.h:1273
int botan_system_rng_get(uint8_t *out, size_t out_len)
Definition ffi_rng.cpp:167
int botan_fpe_destroy(botan_fpe_t fpe)
Definition ffi_fpe.cpp:56
int botan_privkey_oid(botan_asn1_oid_t *oid, botan_privkey_t key)
Definition ffi_pkey.cpp:391
int botan_x509_crl_load(botan_x509_crl_t *crl_obj, const uint8_t crl_bits[], size_t crl_bits_len)
int botan_mp_clear(botan_mp_t mp)
Definition ffi_mp.cpp:35
int botan_pubkey_load_ed448(botan_pubkey_t *key, const uint8_t pubkey[57])
int botan_ec_group_supports_named_group(const char *name, int *out)
Definition ffi_ec.cpp:36
int botan_xof_copy_state(botan_xof_t *dest, botan_xof_t source)
Definition ffi_xof.cpp:39
int botan_x509_cert_get_subject_dn(botan_x509_cert_t cert, const char *key, size_t index, uint8_t out[], size_t *out_len)
Definition ffi_cert.cpp:507
int botan_cipher_is_authenticated(botan_cipher_t cipher)
int botan_mp_view_str(botan_mp_t mp, uint8_t radix, botan_view_ctx ctx, botan_view_str_fn view)
Definition ffi_mp.cpp:110
int botan_privkey_view_encrypted_pem(botan_privkey_t key, botan_rng_t rng, const char *passphrase, const char *cipher_algo, const char *pbkdf_algo, size_t pbkdf_iterations, botan_view_ctx ctx, botan_view_str_fn view)
Definition ffi_pkey.cpp:353
int botan_privkey_load_ml_kem(botan_privkey_t *key, const uint8_t privkey[], size_t key_len, const char *mlkem_mode)
int botan_mp_get_bit(botan_mp_t n, size_t bit)
Definition ffi_mp.cpp:270
int botan_privkey_load_sm2(botan_privkey_t *key, botan_mp_t scalar, const char *curve_name)
int botan_mac_final(botan_mac_t mac, uint8_t out[])
Definition ffi_mac.cpp:60
int botan_pubkey_destroy(botan_pubkey_t key)
Definition ffi_pkey.cpp:132
int botan_ec_group_get_order(botan_mp_t *order, botan_ec_group_t ec_group)
Definition ffi_ec.cpp:184
int botan_x509_cert_dup(botan_x509_cert_t *new_cert, botan_x509_cert_t cert)
Definition ffi_cert.cpp:186
int botan_x509_cert_verify(int *validation_result, botan_x509_cert_t cert, const botan_x509_cert_t *intermediates, size_t intermediates_len, const botan_x509_cert_t *trusted, size_t trusted_len, const char *trusted_path, size_t required_strength, const char *hostname, uint64_t reference_time)
Definition ffi_cert.cpp:950
int botan_privkey_export_encrypted(botan_privkey_t key, uint8_t out[], size_t *out_len, botan_rng_t rng, const char *passphrase, const char *encryption_algo, uint32_t flags)
Definition ffi_pkey.cpp:221
int botan_block_cipher_name(botan_block_cipher_t cipher, char *name, size_t *name_len)
Definition ffi_block.cpp:78
int botan_pk_op_kem_encrypt_create(botan_pk_op_kem_encrypt_t *op, botan_pubkey_t key, const char *kdf)
int botan_rng_get(botan_rng_t rng, uint8_t *out, size_t out_len)
Definition ffi_rng.cpp:163
int(* botan_view_bin_fn)(botan_view_ctx view_ctx, const uint8_t *data, size_t len)
Definition ffi.h:163
int botan_pubkey_load_sm2_enc(botan_pubkey_t *key, botan_mp_t public_x, botan_mp_t public_y, const char *curve_name)
int botan_x509_cert_not_before(botan_x509_cert_t cert, uint64_t *time_since_epoch)
Definition ffi_cert.cpp:622
int botan_hotp_destroy(botan_hotp_t hotp)
Definition ffi_hotp.cpp:44
int botan_mp_sub_u32(botan_mp_t result, botan_mp_t x, uint32_t y)
Definition ffi_mp.cpp:174
int botan_pubkey_x25519_get_pubkey(botan_pubkey_t key, uint8_t pubkey[32])
int botan_pk_op_verify_destroy(botan_pk_op_verify_t op)
int botan_mp_view_bin(botan_mp_t mp, botan_view_ctx ctx, botan_view_bin_fn view)
Definition ffi_mp.cpp:126
int botan_srp6_group_size(const char *group_id, size_t *group_p_bytes)
Definition ffi_srp6.cpp:46
int botan_ec_group_from_oid(botan_ec_group_t *ec_group, botan_asn1_oid_t oid)
Definition ffi_ec.cpp:97
int botan_x509_crl_entry_view_serial_number(botan_x509_crl_entry_t entry, botan_view_ctx ctx, botan_view_bin_fn view)
int botan_xof_destroy(botan_xof_t xof)
Definition ffi_xof.cpp:90
struct botan_x509_cert_struct * botan_x509_cert_t
Definition ffi.h:2231
int botan_mp_num_bits(botan_mp_t n, size_t *bits)
Definition ffi_mp.cpp:282
int botan_privkey_rsa_get_p(botan_mp_t p, botan_privkey_t rsa_key)
int botan_oid_view_string(botan_asn1_oid_t oid, botan_view_ctx ctx, botan_view_str_fn view)
Definition ffi_oid.cpp:50
struct botan_tpm2_ctx_struct * botan_tpm2_ctx_t
Definition ffi.h:3031
int botan_x509_cert_excluded_name_constraints_count(botan_x509_cert_t cert, size_t *count)
Definition ffi_cert.cpp:846
int botan_x509_cert_is_ca(botan_x509_cert_t cert)
Definition ffi_cert.cpp:426
botan_x509_general_name_types
Definition ffi.h:2421
@ BOTAN_X509_DNS_NAME
Definition ffi.h:2424
@ BOTAN_X509_DIRECTORY_NAME
Definition ffi.h:2425
@ BOTAN_X509_OTHER_NAME
Definition ffi.h:2422
@ BOTAN_X509_EMAIL_ADDRESS
Definition ffi.h:2423
@ BOTAN_X509_IP_ADDRESS
Definition ffi.h:2427
@ BOTAN_X509_URI
Definition ffi.h:2426
int botan_privkey_create(botan_privkey_t *key, const char *algo_name, const char *algo_params, botan_rng_t rng)
Definition ffi_pkey.cpp:30
int botan_x509_cert_hostname_match(botan_x509_cert_t cert, const char *hostname)
Definition ffi_cert.cpp:937
int botan_mac_update(botan_mac_t mac, const uint8_t *buf, size_t len)
Definition ffi_mac.cpp:56
int botan_privkey_rsa_get_e(botan_mp_t e, botan_privkey_t rsa_key)
int botan_hotp_check(botan_hotp_t hotp, uint64_t *next_hotp_counter, uint32_t hotp_code, uint64_t hotp_counter, size_t resync_range)
Definition ffi_hotp.cpp:67
int botan_privkey_create_mceliece(botan_privkey_t *key, botan_rng_t rng, size_t n, size_t t)
int botan_x509_cert_load(botan_x509_cert_t *cert_obj, const uint8_t cert[], size_t cert_len)
Definition ffi_cert.cpp:204
int botan_mp_mul(botan_mp_t result, botan_mp_t x, botan_mp_t y)
Definition ffi_mp.cpp:184
struct botan_pk_op_ka_struct * botan_pk_op_ka_t
Definition ffi.h:2108
int botan_privkey_algo_name(botan_privkey_t key, char out[], size_t *out_len)
Definition ffi_pkey.cpp:144
int botan_hash_block_size(botan_hash_t hash, size_t *block_size)
Definition ffi_hash.cpp:48
int botan_ec_group_from_name(botan_ec_group_t *ec_group, const char *name)
Definition ffi_ec.cpp:110
int botan_pubkey_load(botan_pubkey_t *key, const uint8_t bits[], size_t len)
Definition ffi_pkey.cpp:116
int botan_ec_group_supports_application_specific_group(int *out)
Definition ffi_ec.cpp:24
int botan_pk_op_verify_create(botan_pk_op_verify_t *op, botan_pubkey_t key, const char *hash_and_padding, uint32_t flags)
int botan_pubkey_load_x25519(botan_pubkey_t *key, const uint8_t pubkey[32])
int botan_pk_op_key_agreement_view_public(botan_privkey_t key, botan_view_ctx ctx, botan_view_bin_fn view)
int botan_privkey_load_ecdh(botan_privkey_t *key, botan_mp_t scalar, const char *curve_name)
int botan_cipher_get_keyspec(botan_cipher_t cipher, size_t *min_keylen, size_t *max_keylen, size_t *mod_keylen)
int botan_zfec_encode(size_t K, size_t N, const uint8_t *input, size_t size, uint8_t **outputs)
Definition ffi_zfec.cpp:18
int botan_pk_op_kem_encrypt_encapsulated_key_length(botan_pk_op_kem_encrypt_t op, size_t *output_encapsulated_key_length)
int botan_pk_op_verify_finish(botan_pk_op_verify_t op, const uint8_t sig[], size_t sig_len)
struct botan_pk_op_sign_struct * botan_pk_op_sign_t
Definition ffi.h:2069
int botan_x509_crl_entry_create(botan_x509_crl_entry_t *entry, botan_x509_cert_t cert, int reason_code)
int botan_tpm2_ctx_from_esys(botan_tpm2_ctx_t *ctx_out, struct ESYS_CONTEXT *esys_ctx)
Definition ffi_tpm2.cpp:133
int botan_x509_cert_get_serial_number(botan_x509_cert_t cert, uint8_t out[], size_t *out_len)
Definition ffi_cert.cpp:640
int botan_x509_cert_get_subject_key_id(botan_x509_cert_t cert, uint8_t out[], size_t *out_len)
Definition ffi_cert.cpp:687
int botan_pubkey_view_raw(botan_pubkey_t key, botan_view_ctx ctx, botan_view_bin_fn view)
Definition ffi_pkey.cpp:189
botan_x509_cert_key_constraints
Definition ffi.h:2373
@ KEY_ENCIPHERMENT
Definition ffi.h:2377
@ NO_CONSTRAINTS
Definition ffi.h:2374
@ CRL_SIGN
Definition ffi.h:2381
@ DIGITAL_SIGNATURE
Definition ffi.h:2375
@ KEY_AGREEMENT
Definition ffi.h:2379
@ DATA_ENCIPHERMENT
Definition ffi.h:2378
@ KEY_CERT_SIGN
Definition ffi.h:2380
@ ENCIPHER_ONLY
Definition ffi.h:2382
@ NON_REPUDIATION
Definition ffi.h:2376
@ DECIPHER_ONLY
Definition ffi.h:2383
int botan_hash_copy_state(botan_hash_t *dest, botan_hash_t source)
Definition ffi_hash.cpp:79
int botan_pubkey_get_field(botan_mp_t output, botan_pubkey_t key, const char *field_name)
int botan_x509_crl_create(botan_x509_crl_t *crl_obj, botan_rng_t rng, botan_x509_cert_t ca_cert, botan_privkey_t ca_key, uint64_t issue_time, uint32_t next_update, const char *hash_fn, const char *padding)
int botan_pubkey_load_ecdsa(botan_pubkey_t *key, botan_mp_t public_x, botan_mp_t public_y, const char *curve_name)
int botan_ec_group_destroy(botan_ec_group_t ec_group)
Definition ffi_ec.cpp:20
int botan_ec_privkey_create(botan_privkey_t *key, const char *algo_name, botan_ec_group_t ec_group, botan_rng_t rng)
Definition ffi_pkey.cpp:61
int botan_pubkey_load_sm2(botan_pubkey_t *key, botan_mp_t public_x, botan_mp_t public_y, const char *curve_name)
int botan_pk_op_kem_encrypt_create_shared_key(botan_pk_op_kem_encrypt_t op, botan_rng_t rng, const uint8_t salt[], size_t salt_len, size_t desired_shared_key_len, uint8_t shared_key[], size_t *shared_key_len, uint8_t encapsulated_key[], size_t *encapsulated_key_len)
struct botan_mp_struct * botan_mp_t
Definition ffi.h:1003
int botan_pubkey_load_dsa(botan_pubkey_t *key, botan_mp_t p, botan_mp_t q, botan_mp_t g, botan_mp_t y)
int botan_privkey_dsa_get_x(botan_mp_t n, botan_privkey_t key)
struct botan_xof_struct * botan_xof_t
Definition ffi.h:383
void * botan_view_ctx
Definition ffi.h:154
struct botan_rng_struct * botan_rng_t
Definition ffi.h:291
int botan_xof_update(botan_xof_t xof, const uint8_t *in, size_t in_len)
Definition ffi_xof.cpp:66
int botan_ec_group_unregister(botan_asn1_oid_t oid)
Definition ffi_ec.cpp:123
int botan_ec_group_get_b(botan_mp_t *b, botan_ec_group_t ec_group)
Definition ffi_ec.cpp:170
int botan_x509_cert_allowed_extended_usage_str(botan_x509_cert_t cert, const char *oid)
Definition ffi_cert.cpp:569
int botan_block_cipher_destroy(botan_block_cipher_t bc)
Definition ffi_block.cpp:38
int botan_tpm2_supports_crypto_backend(void)
Definition ffi_tpm2.cpp:67
BOTAN_FFI_ERROR
Definition ffi.h:115
@ BOTAN_FFI_ERROR_TPM_ERROR
Definition ffi.h:146
@ BOTAN_FFI_ERROR_NOT_IMPLEMENTED
Definition ffi.h:140
@ BOTAN_FFI_ERROR_INVALID_KEY_LENGTH
Definition ffi.h:136
@ BOTAN_FFI_ERROR_KEY_NOT_SET
Definition ffi.h:135
@ BOTAN_FFI_ERROR_TLS_ERROR
Definition ffi.h:143
@ BOTAN_FFI_ERROR_EXCEPTION_THROWN
Definition ffi.h:127
@ BOTAN_FFI_ERROR_OUT_OF_MEMORY
Definition ffi.h:128
@ BOTAN_FFI_ERROR_OUT_OF_RANGE
Definition ffi.h:138
@ BOTAN_FFI_ERROR_INTERNAL_ERROR
Definition ffi.h:130
@ BOTAN_FFI_INVALID_VERIFIER
Definition ffi.h:118
@ BOTAN_FFI_ERROR_INVALID_OBJECT
Definition ffi.h:141
@ BOTAN_FFI_ERROR_UNKNOWN_ERROR
Definition ffi.h:148
@ BOTAN_FFI_ERROR_HTTP_ERROR
Definition ffi.h:144
@ BOTAN_FFI_ERROR_BAD_FLAG
Definition ffi.h:132
@ BOTAN_FFI_ERROR_INVALID_INPUT
Definition ffi.h:120
@ BOTAN_FFI_ERROR_STRING_CONVERSION_ERROR
Definition ffi.h:125
@ BOTAN_FFI_ERROR_NULL_POINTER
Definition ffi.h:133
@ BOTAN_FFI_SUCCESS
Definition ffi.h:116
@ BOTAN_FFI_ERROR_SYSTEM_ERROR
Definition ffi.h:129
@ BOTAN_FFI_ERROR_ROUGHTIME_ERROR
Definition ffi.h:145
@ BOTAN_FFI_ERROR_NO_VALUE
Definition ffi.h:122
@ BOTAN_FFI_ERROR_INVALID_OBJECT_STATE
Definition ffi.h:137
@ BOTAN_FFI_ERROR_INSUFFICIENT_BUFFER_SPACE
Definition ffi.h:124
@ BOTAN_FFI_ERROR_BAD_MAC
Definition ffi.h:121
@ BOTAN_FFI_ERROR_BAD_PARAMETER
Definition ffi.h:134
int botan_privkey_load_sm2_enc(botan_privkey_t *key, botan_mp_t scalar, const char *curve_name)
struct botan_tpm2_crypto_backend_state_struct * botan_tpm2_crypto_backend_state_t
Definition ffi.h:3041
int botan_pwdhash(const char *algo, size_t param1, size_t param2, size_t param3, uint8_t out[], size_t out_len, const char *passphrase, size_t passphrase_len, const uint8_t salt[], size_t salt_len)
Definition ffi_kdf.cpp:53
int botan_pubkey_load_kyber(botan_pubkey_t *key, const uint8_t pubkey[], size_t key_len)
int botan_mac_name(botan_mac_t mac, char *name, size_t *name_len)
Definition ffi_mac.cpp:64
int botan_oid_view_name(botan_asn1_oid_t oid, botan_view_ctx ctx, botan_view_str_fn view)
Definition ffi_oid.cpp:54
int botan_hotp_init(botan_hotp_t *hotp, const uint8_t key[], size_t key_len, const char *hash_algo, size_t digits)
Definition ffi_hotp.cpp:26
int botan_cipher_clear(botan_cipher_t hash)
struct botan_pk_op_verify_struct * botan_pk_op_verify_t
Definition ffi.h:2089
int botan_x509_cert_view_public_key_bits(botan_x509_cert_t cert, botan_view_ctx ctx, botan_view_bin_fn view)
Definition ffi_cert.cpp:700
int botan_pk_op_decrypt_output_length(botan_pk_op_decrypt_t op, size_t ctext_len, size_t *ptext_len)
Definition ffi_pk_op.cpp:94
int botan_pk_op_encrypt_create(botan_pk_op_encrypt_t *op, botan_pubkey_t key, const char *padding, uint32_t flags)
Definition ffi_pk_op.cpp:28
int botan_mp_is_even(botan_mp_t mp)
Definition ffi_mp.cpp:214
int botan_ec_group_get_p(botan_mp_t *p, botan_ec_group_t ec_group)
Definition ffi_ec.cpp:162
int botan_tpm2_ctx_destroy(botan_tpm2_ctx_t ctx)
Definition ffi_tpm2.cpp:172
int botan_x509_crl_view_string_values(botan_x509_crl_t crl_obj, botan_x509_value_type value_type, size_t index, botan_view_ctx ctx, botan_view_str_fn view)
int botan_pubkey_check_key(botan_pubkey_t key, botan_rng_t rng, uint32_t flags)
Definition ffi_pkey.cpp:152
int botan_x509_crl_verify_signature(botan_x509_crl_t crl, botan_pubkey_t key)
int botan_fpe_encrypt(botan_fpe_t fpe, botan_mp_t x, const uint8_t tweak[], size_t tweak_len)
Definition ffi_fpe.cpp:65
int botan_tpm2_unauthenticated_session_init(botan_tpm2_session_t *session_out, botan_tpm2_ctx_t ctx)
Definition ffi_tpm2.cpp:232
int botan_ec_group_from_ber(botan_ec_group_t *ec_group, const uint8_t *ber, size_t ber_len)
Definition ffi_ec.cpp:71
int botan_rng_destroy(botan_rng_t rng)
Definition ffi_rng.cpp:159
int botan_x509_crl_load_file(botan_x509_crl_t *crl_obj, const char *crl_path)
int botan_pubkey_sm2_compute_za(uint8_t out[], size_t *out_len, const char *ident, const char *hash_algo, botan_pubkey_t key)
int botan_tpm2_crypto_backend_state_destroy(botan_tpm2_crypto_backend_state_t cbs)
Definition ffi_tpm2.cpp:203
int botan_oid_equal(botan_asn1_oid_t a, botan_asn1_oid_t b)
Definition ffi_oid.cpp:59
int botan_hash_final(botan_hash_t hash, uint8_t out[])
Definition ffi_hash.cpp:71
int botan_privkey_load_dsa(botan_privkey_t *key, botan_mp_t p, botan_mp_t q, botan_mp_t g, botan_mp_t x)
int botan_hash_init(botan_hash_t *hash, const char *hash_name, uint32_t flags)
Definition ffi_hash.cpp:18
int botan_mac_get_keyspec(botan_mac_t mac, size_t *out_minimum_keylength, size_t *out_maximum_keylength, size_t *out_keylength_modulo)
Definition ffi_mac.cpp:68
int botan_pubkey_ed25519_get_pubkey(botan_pubkey_t key, uint8_t pubkey[32])
struct botan_cipher_struct * botan_cipher_t
Definition ffi.h:637
int botan_tpm2_session_destroy(botan_tpm2_session_t session)
Definition ffi_tpm2.cpp:249
int botan_cipher_update(botan_cipher_t cipher, uint32_t flags, uint8_t output[], size_t output_size, size_t *output_written, const uint8_t input_bytes[], size_t input_size, size_t *input_consumed)
Encrypt/Decrypt some data and/or finalize the encryption/decryption.
int botan_privkey_load_kyber(botan_privkey_t *key, const uint8_t privkey[], size_t key_len)
int botan_mac_output_length(botan_mac_t mac, size_t *output_length)
Definition ffi_mac.cpp:48
int botan_pk_op_sign_create(botan_pk_op_sign_t *op, botan_privkey_t key, const char *hash_and_padding, uint32_t flags)
int botan_x509_cert_allowed_usage(botan_x509_cert_t cert, unsigned int key_usage)
Definition ffi_cert.cpp:554
int botan_pk_op_encrypt_output_length(botan_pk_op_encrypt_t op, size_t ptext_len, size_t *ctext_len)
Definition ffi_pk_op.cpp:49
int botan_pk_op_key_agreement(botan_pk_op_ka_t op, uint8_t out[], size_t *out_len, const uint8_t other_key[], size_t other_key_len, const uint8_t salt[], size_t salt_len)
int botan_fpe_fe1_init(botan_fpe_t *fpe, botan_mp_t n, const uint8_t key[], size_t key_len, size_t rounds, uint32_t flags)
Definition ffi_fpe.cpp:28
int botan_x509_cert_view_string_values_count(botan_x509_cert_t cert, botan_x509_value_type value_type, size_t *count)
Definition ffi_cert.cpp:414
int botan_pk_op_kem_encrypt_destroy(botan_pk_op_kem_encrypt_t op)
int(* botan_view_str_fn)(botan_view_ctx view_ctx, const char *str, size_t len)
Definition ffi.h:172
int botan_x509_cert_not_after(botan_x509_cert_t cert, uint64_t *time_since_epoch)
Definition ffi_cert.cpp:631
int botan_key_wrap3394(const uint8_t key[], size_t key_len, const uint8_t kek[], size_t kek_len, uint8_t wrapped_key[], size_t *wrapped_key_len)
int botan_pubkey_ed448_get_pubkey(botan_pubkey_t key, uint8_t pubkey[57])
int botan_privkey_rsa_get_d(botan_mp_t d, botan_privkey_t rsa_key)
int botan_pubkey_load_ecdsa_sec1(botan_pubkey_t *key, const uint8_t sec1[], size_t sec1_len, const char *curve_name)
int botan_x509_general_name_view_string_value(botan_x509_general_name_t name, botan_view_ctx ctx, botan_view_str_fn view)
Definition ffi_cert.cpp:735
int botan_ec_group_from_pem(botan_ec_group_t *ec_group, const char *pem)
Definition ffi_ec.cpp:84
int botan_mp_is_negative(botan_mp_t mp)
Definition ffi_mp.cpp:64
int botan_pk_op_encrypt_destroy(botan_pk_op_encrypt_t op)
Definition ffi_pk_op.cpp:45
int botan_pubkey_dsa_get_g(botan_mp_t d, botan_pubkey_t key)
int botan_x509_crl_entry_reason(botan_x509_crl_entry_t entry, int *reason_code)
int botan_mac_set_key(botan_mac_t mac, const uint8_t *key, size_t key_len)
Definition ffi_mac.cpp:40
int botan_x509_cert_get_public_key_bits(botan_x509_cert_t cert, uint8_t out[], size_t *out_len)
Definition ffi_cert.cpp:696
int botan_kdf(const char *kdf_algo, uint8_t out[], size_t out_len, const uint8_t secret[], size_t secret_len, const uint8_t salt[], size_t salt_len, const uint8_t label[], size_t label_len)
Definition ffi_kdf.cpp:130
int botan_pubkey_dsa_get_q(botan_mp_t q, botan_pubkey_t key)
int botan_privkey_load_frodokem(botan_privkey_t *key, const uint8_t privkey[], size_t key_len, const char *frodo_mode)
int botan_mp_sub(botan_mp_t result, botan_mp_t x, botan_mp_t y)
Definition ffi_mp.cpp:154
int botan_privkey_create_ecdh(botan_privkey_t *key, botan_rng_t rng, const char *params)
int botan_privkey_load_ecdsa(botan_privkey_t *key, botan_mp_t scalar, const char *curve_name)
int botan_xof_accepts_input(botan_xof_t xof)
Definition ffi_xof.cpp:58
int botan_x509_cert_get_fingerprint(botan_x509_cert_t cert, const char *hash, uint8_t out[], size_t *out_len)
Definition ffi_cert.cpp:665
int botan_rng_init(botan_rng_t *rng, const char *rng_type)
Definition ffi_rng.cpp:33
int botan_x509_cert_get_path_length_constraint(botan_x509_cert_t cert, size_t *path_limit)
Definition ffi_cert.cpp:435
int botan_block_cipher_encrypt_blocks(botan_block_cipher_t bc, const uint8_t in[], uint8_t out[], size_t blocks)
Definition ffi_block.cpp:64
int botan_privkey_load_ml_dsa(botan_privkey_t *key, const uint8_t privkey[], size_t key_len, const char *mldsa_mode)
int botan_pk_op_kem_decrypt_shared_key_length(botan_pk_op_kem_decrypt_t op, size_t desired_shared_key_length, size_t *output_shared_key_length)
int botan_totp_check(botan_totp_t totp, uint32_t totp_code, uint64_t timestamp, size_t acceptable_clock_drift)
Definition ffi_totp.cpp:68
int botan_x509_cert_to_string(botan_x509_cert_t cert, char out[], size_t *out_len)
Definition ffi_cert.cpp:541
int botan_cipher_get_default_nonce_length(botan_cipher_t cipher, size_t *nl)
int botan_pk_op_kem_decrypt_destroy(botan_pk_op_kem_decrypt_t op)
int botan_pk_op_sign_destroy(botan_pk_op_sign_t op)
int botan_privkey_x448_get_privkey(botan_privkey_t key, uint8_t output[56])
int botan_mp_is_positive(botan_mp_t mp)
Definition ffi_mp.cpp:68
int botan_privkey_load_ed25519(botan_privkey_t *key, const uint8_t privkey[32])
struct botan_fpe_struct * botan_fpe_t
Definition ffi.h:2850
int botan_privkey_view_pem(botan_privkey_t key, botan_view_ctx ctx, botan_view_str_fn view)
Definition ffi_pkey.cpp:211
int botan_oid_destroy(botan_asn1_oid_t oid)
Definition ffi_oid.cpp:18
int botan_privkey_x25519_get_privkey(botan_privkey_t key, uint8_t output[32])
int botan_nist_kw_dec(const char *cipher_algo, int padded, const uint8_t wrapped_key[], size_t wrapped_key_len, const uint8_t kek[], size_t kek_len, uint8_t key[], size_t *key_len)
int botan_privkey_ed448_get_privkey(botan_privkey_t key, uint8_t output[57])
int botan_privkey_export_encrypted_pbkdf_msec(botan_privkey_t key, uint8_t out[], size_t *out_len, botan_rng_t rng, const char *passphrase, uint32_t pbkdf_msec_runtime, size_t *pbkdf_iterations_out, const char *cipher_algo, const char *pbkdf_algo, uint32_t flags)
Definition ffi_pkey.cpp:231
int botan_x509_crl_view_string_values_count(botan_x509_crl_t crl_obj, botan_x509_value_type value_type, size_t *count)
int botan_cipher_query_keylen(botan_cipher_t cipher, size_t *out_minimum_keylength, size_t *out_maximum_keylength)
int botan_cipher_get_update_granularity(botan_cipher_t cipher, size_t *ug)
int botan_pubkey_load_rsa(botan_pubkey_t *key, botan_mp_t n, botan_mp_t e)
int botan_pbkdf_timed(const char *pbkdf_algo, uint8_t out[], size_t out_len, const char *passphrase, const uint8_t salt[], size_t salt_len, size_t milliseconds_to_run, size_t *out_iterations_used)
Definition ffi_kdf.cpp:32
int botan_x509_general_name_get_type(botan_x509_general_name_t name, unsigned int *type)
Definition ffi_cert.cpp:710
int botan_mac_clear(botan_mac_t mac)
Definition ffi_mac.cpp:52
int botan_pubkey_view_kyber_raw_key(botan_pubkey_t key, botan_view_ctx ctx, botan_view_bin_fn view)
int botan_x509_cert_permitted_name_constraints_count(botan_x509_cert_t cert, size_t *count)
Definition ffi_cert.cpp:811
int botan_block_cipher_set_key(botan_block_cipher_t bc, const uint8_t key[], size_t len)
Definition ffi_block.cpp:49
int botan_mp_set_bit(botan_mp_t n, size_t bit)
Definition ffi_mp.cpp:274
int botan_bcrypt_is_valid(const char *pass, const char *hash)
Definition ffi_kdf.cpp:189
int botan_mp_set_from_mp(botan_mp_t dest, botan_mp_t source)
Definition ffi_mp.cpp:60
struct botan_hash_struct * botan_hash_t
Definition ffi.h:461
botan_x509_value_type
Definition ffi.h:2246
@ BOTAN_X509_AUTHORITY_KEY_IDENTIFIER
Definition ffi.h:2251
@ BOTAN_X509_SUBJECT_KEY_IDENTIFIER
Definition ffi.h:2250
@ BOTAN_X509_TBS_DATA_BITS
Definition ffi.h:2254
@ BOTAN_X509_SIGNATURE_BITS
Definition ffi.h:2256
@ BOTAN_X509_PUBLIC_KEY_PKCS8_BITS
Definition ffi.h:2253
@ BOTAN_X509_DER_ENCODING
Definition ffi.h:2258
@ BOTAN_X509_PEM_ENCODING
Definition ffi.h:2259
@ BOTAN_X509_OCSP_RESPONDER_URLS
Definition ffi.h:2262
@ BOTAN_X509_SIGNATURE_SCHEME_BITS
Definition ffi.h:2255
@ BOTAN_X509_SUBJECT_DN_BITS
Definition ffi.h:2248
@ BOTAN_X509_CRL_DISTRIBUTION_URLS
Definition ffi.h:2261
@ BOTAN_X509_SERIAL_NUMBER
Definition ffi.h:2247
@ BOTAN_X509_ISSUER_DN_BITS
Definition ffi.h:2249
@ BOTAN_X509_CA_ISSUERS_URLS
Definition ffi.h:2263
int botan_x509_crl_view_binary_values(botan_x509_crl_t crl_obj, botan_x509_value_type value_type, size_t index, botan_view_ctx ctx, botan_view_bin_fn view)
int botan_pubkey_load_x448(botan_pubkey_t *key, const uint8_t pubkey[56])
int botan_privkey_create_elgamal(botan_privkey_t *key, botan_rng_t rng_obj, size_t pbits, size_t qbits)
int botan_pubkey_load_dh(botan_pubkey_t *key, botan_mp_t p, botan_mp_t g, botan_mp_t y)
int botan_pubkey_load_elgamal(botan_pubkey_t *key, botan_mp_t p, botan_mp_t g, botan_mp_t y)
int botan_privkey_create_dsa(botan_privkey_t *key, botan_rng_t rng_obj, size_t pbits, size_t qbits)
int botan_privkey_load_elgamal(botan_privkey_t *key, botan_mp_t p, botan_mp_t g, botan_mp_t x)