Botan 3.10.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*
6* Botan is released under the Simplified BSD License (see license.txt)
7*/
8
9#ifndef BOTAN_FFI_H_
10#define BOTAN_FFI_H_
11
12#ifdef __cplusplus
13extern "C" {
14#endif
15
16/*
17This header exports some of botan's functionality via a C89 interface. This API
18is used by the Python, OCaml, Rust, Ruby, and Haskell bindings via those languages
19respective ctypes/FFI libraries.
20
21The API is intended to be as easy as possible to call from other
22languages, which often have easy ways to call C, because C. But some C
23code is easier to deal with than others, so to make things easy this
24API follows a few simple rules:
25
26- All interactions are via pointers to opaque structs. No need to worry about
27 structure padding issues and the like.
28
29- All functions return an int error code (except the version calls, which are
30 assumed to always have something to say).
31
32- Use simple types: size_t for lengths, const char* NULL terminated strings,
33 uint8_t for binary.
34
35- No ownership of memory transfers across the API boundary. The API will consume
36 data from const pointers with specified lengths. Outputs are either placed into
37 buffers provided by (and allocated by) the caller, or are returned via a
38 callback (what the FFI layer calls "view" functions).
39
40 When writing to an application-provided buffer, the function takes a pointer
41 to the output array and a read/write pointer to the length. The length field
42 is always set to the actual amount of data that would have been written. If
43 the input buffer's size was insufficient an error is returned.
44
45 In many situations the length of the output can be known in advance without
46 difficulty, in which case there will be a function which allows querying the
47 expected output length. For example `botan_hash_output_length` allows knowing
48 in advance the expected size for `botan_hash_final`. Some of these are exact,
49 while others such as `botan_pk_op_decrypt_output_length` can only provide an
50 upper bound for various technical reasons.
51
52 In some cases knowing the exact size is difficult or impossible. In these
53 situations view functions are used; see the handbook for further details.
54
55 TODO: Doxygen comments for all parameters
56*/
57
58#include <stddef.h>
59#include <stdint.h>
60
61/* NOLINTBEGIN(*-macro-usage,*-misplaced-const) */
62
63/**
64* The compile time API version. This matches the value of
65* botan_ffi_api_version. This can be used for compile-time checking if a
66* particular feature is available.
67*
68* Note this same value is also reflected in BOTAN_HAS_FFI in build.h, however
69* that declaration is not visible here since this header is intentionally
70* free-standing, depending only on a few C standard library headers.
71*/
72#define BOTAN_FFI_API_VERSION 20250829
73
74/**
75* BOTAN_FFI_EXPORT indicates public FFI functions.
76*
77* The arguments to the macro are to indicate the version that
78* that particular FFI function was first available
79*/
80#if defined(BOTAN_DLL)
81 #define BOTAN_FFI_EXPORT(maj, min) BOTAN_DLL
82#else
83 #if defined(__has_attribute)
84 #if __has_attribute(visibility)
85 #define BOTAN_FFI_EXPORT(maj, min) __attribute__((visibility("default")))
86 #endif
87 #elif defined(_MSC_VER) && !defined(BOTAN_IS_BEING_BUILT)
88 #define BOTAN_FFI_EXPORT(maj, min) __declspec(dllimport)
89 #else
90 #define BOTAN_FFI_EXPORT(maj, min)
91 #endif
92#endif
93
94#if !defined(BOTAN_NO_DEPRECATED_WARNINGS) && !defined(BOTAN_AMALGAMATION_H_) && !defined(BOTAN_IS_BEING_BUILT)
95 #if defined(__has_attribute)
96 #if __has_attribute(deprecated)
97 #define BOTAN_FFI_DEPRECATED(msg) __attribute__((deprecated(msg)))
98 #endif
99 #elif defined(_MSC_VER)
100 #define BOTAN_FFI_DEPRECATED(msg) __declspec(deprecated(msg))
101 #endif
102#endif
103
104#if !defined(BOTAN_FFI_DEPRECATED)
105 #define BOTAN_FFI_DEPRECATED(msg) /**/
106#endif
107
108/**
109* Error codes
110*
111* If you add a new value here be sure to also add it in
112* botan_error_description
113*/
148
149/**
150* The application provided context for a view function
151*/
152typedef void* botan_view_ctx;
153
154/**
155* Viewer function for binary data
156*
157* @param view_ctx some application context
158* @param data the binary data
159* @param len the length of data in bytes
160*/
161typedef int (*botan_view_bin_fn)(botan_view_ctx view_ctx, const uint8_t* data, size_t len);
162
163/**
164* Viewer function for string data
165*
166* @param view_ctx some application context
167* @param str the null terminated string
168* @param len the length of string *including* the null terminator
169*/
170typedef int (*botan_view_str_fn)(botan_view_ctx view_ctx, const char* str, size_t len);
171
172/**
173* Convert an error code into a string. Returns "Unknown error"
174* if the error code is not a known one.
175*/
176BOTAN_FFI_EXPORT(2, 8) const char* botan_error_description(int err);
177
178/**
179* Return the message of the last exception caught in this thread.
180*
181* This pointer can/will be reallocated or overwritten the next time
182* this thread calls any other Botan FFI function and must be copied
183* to persistent storage first.
184*/
186
187/**
188* Return the version of the currently supported FFI API. This is
189* expressed in the form YYYYMMDD of the release date of this version
190* of the API.
191*/
192BOTAN_FFI_EXPORT(2, 0) uint32_t botan_ffi_api_version(void);
193
194/**
195* Return 0 (ok) if the version given is one this library supports.
196* botan_ffi_supports_api(botan_ffi_api_version()) will always return 0.
197*/
198BOTAN_FFI_EXPORT(2, 0) int botan_ffi_supports_api(uint32_t api_version);
199
200/**
201* Return a free-form version string, e.g., 2.0.0
202*/
203BOTAN_FFI_EXPORT(2, 0) const char* botan_version_string(void);
204
205/**
206* Return the major version of the library
207*/
208BOTAN_FFI_EXPORT(2, 0) uint32_t botan_version_major(void);
209
210/**
211* Return the minor version of the library
212*/
213BOTAN_FFI_EXPORT(2, 0) uint32_t botan_version_minor(void);
214
215/**
216* Return the patch version of the library
217*/
218BOTAN_FFI_EXPORT(2, 0) uint32_t botan_version_patch(void);
219
220/**
221* Return the date this version was released as an integer.
222*
223* Returns 0 if the library was not built from an official release
224*/
225BOTAN_FFI_EXPORT(2, 0) uint32_t botan_version_datestamp(void);
226
227/**
228* Returns 0 if x[0..len] == y[0..len], or otherwise -1
229*/
230BOTAN_FFI_EXPORT(2, 3) int botan_constant_time_compare(const uint8_t* x, const uint8_t* y, size_t len);
231
232/**
233* Deprecated equivalent to botan_constant_time_compare
234*/
235BOTAN_FFI_DEPRECATED("Use botan_constant_time_compare")
236BOTAN_FFI_EXPORT(2, 0) int botan_same_mem(const uint8_t* x, const uint8_t* y, size_t len);
237
238/**
239* Clear out memory using a system specific approach to bypass elision by the
240* compiler (currently using RtlSecureZeroMemory or tricks with volatile pointers).
241*/
242BOTAN_FFI_EXPORT(2, 2) int botan_scrub_mem(void* mem, size_t bytes);
243
244/**
245* Flag that can be provided to botan_hex_encode to request lower case hex
246*/
247#define BOTAN_FFI_HEX_LOWER_CASE 1
248
249/**
250* Perform hex encoding
251* @param x is some binary data
252* @param len length of x in bytes
253* @param out an array of at least x*2 bytes
254* @param flags flags out be upper or lower case?
255* @return 0 on success, a negative value on failure
256*/
257BOTAN_FFI_EXPORT(2, 0) int botan_hex_encode(const uint8_t* x, size_t len, char* out, uint32_t flags);
258
259/**
260* Perform hex decoding
261* @param hex_str a string of hex chars (whitespace is ignored)
262* @param in_len the length of hex_str
263* @param out the output buffer should be at least strlen(hex_str)/2 bytes
264* @param out_len the size of the output buffer on input, set to the number of bytes written
265* @return 0 on success, a negative value on failure
266*/
267BOTAN_FFI_EXPORT(2, 3) int botan_hex_decode(const char* hex_str, size_t in_len, uint8_t* out, size_t* out_len);
268
269/**
270* Perform base64 encoding
271*
272* @param x the input data
273* @param len the length of x
274* @param out the output buffer
275* @param out_len the size of the output buffer on input, set to the number of bytes written
276* @return 0 on success, a negative value on failure
277
278*/
279BOTAN_FFI_EXPORT(2, 3) int botan_base64_encode(const uint8_t* x, size_t len, char* out, size_t* out_len);
280
281/**
282* Perform base64 decoding
283*/
284BOTAN_FFI_EXPORT(2, 3) int botan_base64_decode(const char* base64_str, size_t in_len, uint8_t* out, size_t* out_len);
285
286/**
287* RNG type
288*/
289typedef struct botan_rng_struct* botan_rng_t;
290
291/**
292* Initialize a random number generator object
293* @param rng rng object
294* @param rng_type type of the rng, possible values:
295* "system": system RNG
296* "esdm-full": ESDM RNG (fully seeded)
297* "esdm-pr": ESDM RNG (w. prediction resistance)
298* "user": userspace RNG
299* "user-threadsafe": userspace RNG, with internal locking
300* "rdrand": directly read RDRAND
301* Set rng_type to null to let the library choose some default.
302*/
303BOTAN_FFI_EXPORT(2, 0) int botan_rng_init(botan_rng_t* rng, const char* rng_type);
304
305/**
306* Initialize a custom random number generator from a set of callback functions
307* @param rng_out rng object to create
308* @param rng_name name of the rng
309* @param context An application-specific context passed to the callback functions
310* @param get_cb Callback for getting random bytes from the rng, return 0 for success
311* @param add_entropy_cb Callback for adding entropy to the rng, return 0 for success, may be NULL
312* @param destroy_cb Callback called when rng is destroyed, may be NULL
313*/
316 const char* rng_name,
317 void* context,
318 int (*get_cb)(void* context, uint8_t* out, size_t out_len),
319 int (*add_entropy_cb)(void* context, const uint8_t input[], size_t length),
320 void (*destroy_cb)(void* context));
321
322/**
323* Get random bytes from a random number generator
324*
325* @param rng rng object
326* @param out output buffer of size out_len
327* @param out_len number of requested bytes
328* @return 0 on success, negative on failure
329*/
330BOTAN_FFI_EXPORT(2, 0) int botan_rng_get(botan_rng_t rng, uint8_t* out, size_t out_len);
331
332/**
333* Get random bytes from system random number generator
334*
335* @param out output buffer of size out_len
336* @param out_len number of requested bytes
337* @return 0 on success, negative on failure
338*/
339BOTAN_FFI_EXPORT(3, 0) int botan_system_rng_get(uint8_t* out, size_t out_len);
340
341/**
342* Reseed a random number generator
343* Uses the System_RNG as a seed generator.
344*
345* @param rng rng object
346* @param bits number of bits to reseed with
347* @return 0 on success, a negative value on failure
348*/
349BOTAN_FFI_EXPORT(2, 0) int botan_rng_reseed(botan_rng_t rng, size_t bits);
350
351/**
352* Reseed a random number generator
353*
354* @param rng rng object
355* @param source_rng the rng that will be read from
356* @param bits number of bits to reseed with
357* @return 0 on success, a negative value on failure
358*/
359BOTAN_FFI_EXPORT(2, 8) int botan_rng_reseed_from_rng(botan_rng_t rng, botan_rng_t source_rng, size_t bits);
360
361/**
362* Add some seed material to a random number generator
363*
364* @param rng rng object
365* @param entropy the data to add
366* @param entropy_len length of entropy buffer
367* @return 0 on success, a negative value on failure
368*/
369BOTAN_FFI_EXPORT(2, 8) int botan_rng_add_entropy(botan_rng_t rng, const uint8_t* entropy, size_t entropy_len);
370
371/**
372* Frees all resources of the random number generator object
373* @param rng rng object
374* @return 0 if success, error if invalid object handle
375*/
377
378/*
379* Opaque type of a hash function
380*/
381typedef struct botan_hash_struct* botan_hash_t;
382
383/**
384* Initialize a hash function object
385* @param hash hash object
386* @param hash_name name of the hash function, e.g., "SHA-384"
387* @param flags should be 0 in current API revision, all other uses are reserved
388* and return BOTAN_FFI_ERROR_BAD_FLAG
389*/
390BOTAN_FFI_EXPORT(2, 0) int botan_hash_init(botan_hash_t* hash, const char* hash_name, uint32_t flags);
391
392/**
393* Copy the state of a hash function object
394* @param dest destination hash object
395* @param source source hash object
396* @return 0 on success, a negative value on failure
397*/
399
400/**
401* Writes the output length of the hash function to *output_length
402* @param hash hash object
403* @param output_length output buffer to hold the hash function output length
404* @return 0 on success, a negative value on failure
405*/
406BOTAN_FFI_EXPORT(2, 0) int botan_hash_output_length(botan_hash_t hash, size_t* output_length);
407
408/**
409* Writes the block size of the hash function to *block_size
410* @param hash hash object
411* @param block_size output buffer to hold the hash function output length
412* @return 0 on success, a negative value on failure
413*/
414BOTAN_FFI_EXPORT(2, 2) int botan_hash_block_size(botan_hash_t hash, size_t* block_size);
415
416/**
417* Send more input to the hash function
418* @param hash hash object
419* @param in input buffer
420* @param in_len number of bytes to read from the input buffer
421* @return 0 on success, a negative value on failure
422*/
423BOTAN_FFI_EXPORT(2, 0) int botan_hash_update(botan_hash_t hash, const uint8_t* in, size_t in_len);
424
425/**
426* Finalizes the hash computation and writes the output to
427* out[0:botan_hash_output_length()] then reinitializes for computing
428* another digest as if botan_hash_clear had been called.
429* @param hash hash object
430* @param out output buffer
431* @return 0 on success, a negative value on failure
432*/
433BOTAN_FFI_EXPORT(2, 0) int botan_hash_final(botan_hash_t hash, uint8_t out[]);
434
435/**
436* Reinitializes the state of the hash computation. A hash can
437* be computed (with update/final) immediately.
438* @param hash hash object
439* @return 0 on success, a negative value on failure
440*/
442
443/**
444* Frees all resources of the hash object
445* @param hash hash object
446* @return 0 if success, error if invalid object handle
447*/
449
450/**
451* Get the name of this hash function
452* @param hash the object to read
453* @param name output buffer
454* @param name_len on input, the length of buffer, on success the number of bytes written
455*/
456BOTAN_FFI_EXPORT(2, 8) int botan_hash_name(botan_hash_t hash, char* name, size_t* name_len);
457
458/*
459* Opaque type of a message authentication code
460*/
461typedef struct botan_mac_struct* botan_mac_t;
462
463/**
464* Initialize a message authentication code object
465* @param mac mac object
466* @param mac_name name of the hash function, e.g., "HMAC(SHA-384)"
467* @param flags should be 0 in current API revision, all other uses are reserved
468* and return a negative value (error code)
469* @return 0 on success, a negative value on failure
470*/
471BOTAN_FFI_EXPORT(2, 0) int botan_mac_init(botan_mac_t* mac, const char* mac_name, uint32_t flags);
472
473/**
474* Writes the output length of the message authentication code to *output_length
475* @param mac mac object
476* @param output_length output buffer to hold the MAC output length
477* @return 0 on success, a negative value on failure
478*/
479BOTAN_FFI_EXPORT(2, 0) int botan_mac_output_length(botan_mac_t mac, size_t* output_length);
480
481/**
482* Sets the key on the MAC
483* @param mac mac object
484* @param key buffer holding the key
485* @param key_len size of the key buffer in bytes
486* @return 0 on success, a negative value on failure
487*/
488BOTAN_FFI_EXPORT(2, 0) int botan_mac_set_key(botan_mac_t mac, const uint8_t* key, size_t key_len);
489
490/**
491* Sets the nonce on the MAC
492* @param mac mac object
493* @param nonce buffer holding the key
494* @param nonce_len size of the key buffer in bytes
495* @return 0 on success, a negative value on failure
496*/
497BOTAN_FFI_EXPORT(3, 0) int botan_mac_set_nonce(botan_mac_t mac, const uint8_t* nonce, size_t nonce_len);
498
499/**
500* Send more input to the message authentication code
501* @param mac mac object
502* @param buf input buffer
503* @param len number of bytes to read from the input buffer
504* @return 0 on success, a negative value on failure
505*/
506BOTAN_FFI_EXPORT(2, 0) int botan_mac_update(botan_mac_t mac, const uint8_t* buf, size_t len);
507
508/**
509* Finalizes the MAC computation and writes the output to
510* out[0:botan_mac_output_length()] then reinitializes for computing
511* another MAC as if botan_mac_clear had been called.
512* @param mac mac object
513* @param out output buffer
514* @return 0 on success, a negative value on failure
515*/
516BOTAN_FFI_EXPORT(2, 0) int botan_mac_final(botan_mac_t mac, uint8_t out[]);
517
518/**
519* Reinitializes the state of the MAC computation. A MAC can
520* be computed (with update/final) immediately.
521* @param mac mac object
522* @return 0 on success, a negative value on failure
523*/
525
526/**
527* Get the name of this MAC
528* @param mac the object to read
529* @param name output buffer
530* @param name_len on input, the length of buffer, on success the number of bytes written
531*/
532BOTAN_FFI_EXPORT(2, 8) int botan_mac_name(botan_mac_t mac, char* name, size_t* name_len);
533
534/**
535* Get the key length limits of this auth code
536* @param mac the object to read
537* @param out_minimum_keylength if non-NULL, will be set to minimum keylength of MAC
538* @param out_maximum_keylength if non-NULL, will be set to maximum keylength of MAC
539* @param out_keylength_modulo if non-NULL will be set to byte multiple of valid keys
540*/
543 size_t* out_minimum_keylength,
544 size_t* out_maximum_keylength,
545 size_t* out_keylength_modulo);
546
547/**
548* Frees all resources of the MAC object
549* @param mac mac object
550* @return 0 if success, error if invalid object handle
551*/
553
554/*
555* Opaque type of a cipher mode
556*/
557typedef struct botan_cipher_struct* botan_cipher_t;
558
559#define BOTAN_CIPHER_INIT_FLAG_MASK_DIRECTION 1
560#define BOTAN_CIPHER_INIT_FLAG_ENCRYPT 0
561#define BOTAN_CIPHER_INIT_FLAG_DECRYPT 1
562
563/**
564* Initialize a cipher object
565*/
566BOTAN_FFI_EXPORT(2, 0) int botan_cipher_init(botan_cipher_t* cipher, const char* name, uint32_t flags);
567
568/**
569* Return the name of the cipher object
570*/
571BOTAN_FFI_EXPORT(2, 8) int botan_cipher_name(botan_cipher_t cipher, char* name, size_t* name_len);
572
573/**
574* Return the output length of this cipher, for a particular input length.
575*/
576BOTAN_FFI_EXPORT(2, 8) int botan_cipher_output_length(botan_cipher_t cipher, size_t in_len, size_t* out_len);
577
578/**
579* Return if the specified nonce length is valid for this cipher
580*/
582
583/**
584* Get the tag length of the cipher (0 for non-AEAD modes)
585*/
586BOTAN_FFI_EXPORT(2, 0) int botan_cipher_get_tag_length(botan_cipher_t cipher, size_t* tag_size);
587
588/**
589* Returns 1 iff the cipher provides authentication as well as confidentiality.
590*/
592
593/**
594 * Returns 1 iff the cipher requires the entire message before any
595 * encryption or decryption can be performed. No output data will be produced
596 * in botan_cipher_update() until the final flag is set.
597 */
599
600/**
601* Get the default nonce length of this cipher
602*/
604
605/**
606* Return the update granularity of the cipher; botan_cipher_update must be
607* called with blocks of this size, except for the final.
608*/
610
611/**
612* Return the ideal update granularity of the cipher. This is some multiple of the
613* update granularity, reflecting possibilities for optimization.
614*/
616
617/**
618* Get information about the key lengths. Prefer botan_cipher_get_keyspec
619*/
621int botan_cipher_query_keylen(botan_cipher_t cipher, size_t* out_minimum_keylength, size_t* out_maximum_keylength);
622
623/**
624* Get information about the supported key lengths.
625*/
627int botan_cipher_get_keyspec(botan_cipher_t cipher, size_t* min_keylen, size_t* max_keylen, size_t* mod_keylen);
628
629/**
630* Set the key for this cipher object
631*/
632BOTAN_FFI_EXPORT(2, 0) int botan_cipher_set_key(botan_cipher_t cipher, const uint8_t* key, size_t key_len);
633
634/**
635* Reset the message specific state for this cipher.
636* Without resetting the keys, this resets the nonce, and any state
637* associated with any message bits that have been processed so far.
638*
639* It is conceptually equivalent to calling botan_cipher_clear followed
640* by botan_cipher_set_key with the original key.
641*/
643
644/**
645* Set the associated data. Will fail if cipher is not an AEAD
646*/
647BOTAN_FFI_EXPORT(2, 0) int botan_cipher_set_associated_data(botan_cipher_t cipher, const uint8_t* ad, size_t ad_len);
648
649/**
650* Begin processing a new message using the provided nonce
651*/
652BOTAN_FFI_EXPORT(2, 0) int botan_cipher_start(botan_cipher_t cipher, const uint8_t* nonce, size_t nonce_len);
653
654#define BOTAN_CIPHER_UPDATE_FLAG_FINAL (1U << 0)
655
656/**
657* @brief Encrypt/Decrypt some data and/or finalize the encryption/decryption
658*
659* This encrypts as many bytes from @p input_bytes into @p output_bytes as
660* possible. Unless ``BOTAN_CIPHER_UPDATE_FLAG_FINAL`` is set, this function will
661* consume bytes in multiples of botan_cipher_get_update_granularity().
662* @p input_consumed and @p output_written will be set accordingly and it is the
663* caller's responsibility to adapt their buffers accordingly before calling this
664* function again. Note that, unless ``BOTAN_CIPHER_UPDATE_FLAG_FINAL`` is set,
665* the cipher will at most generate @p input_size output bytes.
666*
667* Eventually, the caller must set the ``BOTAN_CIPHER_UPDATE_FLAG_FINAL`` flag to
668* indicate that no more input will be provided. This will cause the cipher to
669* consume all given input bytes and produce the final output; or return a
670* ``BOTAN_FFI_ERROR_INSUFFICIENT_BUFFER_SPACE`` error if the given output buffer
671* was too small. In the latter case, @p output_written will be set to the
672* required buffer size. Calling again with ``BOTAN_CIPHER_UPDATE_FLAG_FINAL``, a
673* big enough buffer and no further input will then produce the final output.
674*
675* Note that some ciphers require the entire message to be provided before any
676* output is produced. @sa botan_cipher_requires_entire_message().
677*/
680 uint32_t flags,
681 uint8_t output[],
682 size_t output_size,
683 size_t* output_written,
684 const uint8_t input_bytes[],
685 size_t input_size,
686 size_t* input_consumed);
687
688/**
689* Reset the key, nonce, AD and all other state on this cipher object
690*/
692
693/**
694* Destroy the cipher object
695* @return 0 if success, error if invalid object handle
696*/
698
699/*
700* Derive a key from a passphrase for a number of iterations
701* @param pbkdf_algo PBKDF algorithm, e.g., "PBKDF2(SHA-256)"
702* @param out buffer to store the derived key, must be of out_len bytes
703* @param out_len the desired length of the key to produce
704* @param passphrase the password to derive the key from
705* @param salt a randomly chosen salt
706* @param salt_len length of salt in bytes
707* @param iterations the number of iterations to use (use 10K or more)
708* @return 0 on success, a negative value on failure
709*
710* Deprecated: use
711* botan_pwdhash(pbkdf_algo, iterations, 0, 0, out, out_len,
712* passphrase, 0, salt, salt_len);
713*/
714BOTAN_FFI_DEPRECATED("Use botan_pwdhash")
716int botan_pbkdf(const char* pbkdf_algo,
717 uint8_t out[],
718 size_t out_len,
719 const char* passphrase,
720 const uint8_t salt[],
721 size_t salt_len,
722 size_t iterations);
723
724/**
725* Derive a key from a passphrase, running until msec time has elapsed.
726* @param pbkdf_algo PBKDF algorithm, e.g., "PBKDF2(SHA-256)"
727* @param out buffer to store the derived key, must be of out_len bytes
728* @param out_len the desired length of the key to produce
729* @param passphrase the password to derive the key from
730* @param salt a randomly chosen salt
731* @param salt_len length of salt in bytes
732* @param milliseconds_to_run if iterations is zero, then instead the PBKDF is
733* run until milliseconds_to_run milliseconds has passed
734* @param out_iterations_used set to the number iterations executed
735* @return 0 on success, a negative value on failure
736*
737* Deprecated: use
738*
739* botan_pwdhash_timed(pbkdf_algo,
740* static_cast<uint32_t>(ms_to_run),
741* iterations_used,
742* nullptr,
743* nullptr,
744* out, out_len,
745* password, 0,
746* salt, salt_len);
747*/
749int botan_pbkdf_timed(const char* pbkdf_algo,
750 uint8_t out[],
751 size_t out_len,
752 const char* passphrase,
753 const uint8_t salt[],
754 size_t salt_len,
755 size_t milliseconds_to_run,
756 size_t* out_iterations_used);
757
758/*
759* Derive a key from a passphrase
760* @param algo PBKDF algorithm, e.g., "PBKDF2(SHA-256)" or "Scrypt"
761* @param param1 the first PBKDF algorithm parameter
762* @param param2 the second PBKDF algorithm parameter (may be zero if unneeded)
763* @param param3 the third PBKDF algorithm parameter (may be zero if unneeded)
764* @param out buffer to store the derived key, must be of out_len bytes
765* @param out_len the desired length of the key to produce
766* @param passphrase the password to derive the key from
767* @param passphrase_len if > 0, specifies length of password. If len == 0, then
768* strlen will be called on passphrase to compute the length.
769* @param salt a randomly chosen salt
770* @param salt_len length of salt in bytes
771* @return 0 on success, a negative value on failure
772*/
773int BOTAN_FFI_EXPORT(2, 8) botan_pwdhash(const char* algo,
774 size_t param1,
775 size_t param2,
776 size_t param3,
777 uint8_t out[],
778 size_t out_len,
779 const char* passphrase,
780 size_t passphrase_len,
781 const uint8_t salt[],
782 size_t salt_len);
783
784/*
785* Derive a key from a passphrase
786* @param pbkdf_algo PBKDF algorithm, e.g., "Scrypt" or "PBKDF2(SHA-256)"
787* @param msec the desired runtime in milliseconds
788* @param param1 will be set to the first password hash parameter
789* @param param2 will be set to the second password hash parameter
790* @param param3 will be set to the third password hash parameter
791* @param out buffer to store the derived key, must be of out_len bytes
792* @param out_len the desired length of the key to produce
793* @param passphrase the password to derive the key from
794* @param passphrase_len if > 0, specifies length of password. If len == 0, then
795* strlen will be called on passphrase to compute the length.
796* @param salt a randomly chosen salt
797* @param salt_len length of salt in bytes
798* @return 0 on success, a negative value on failure
799*/
800int BOTAN_FFI_EXPORT(2, 8) botan_pwdhash_timed(const char* algo,
801 uint32_t msec,
802 size_t* param1,
803 size_t* param2,
804 size_t* param3,
805 uint8_t out[],
806 size_t out_len,
807 const char* passphrase,
808 size_t passphrase_len,
809 const uint8_t salt[],
810 size_t salt_len);
811
812/**
813* Derive a key using scrypt
814* Deprecated; use
815* botan_pwdhash("Scrypt", N, r, p, out, out_len, password, 0, salt, salt_len);
816*/
817BOTAN_FFI_DEPRECATED("Use botan_pwdhash")
819int botan_scrypt(uint8_t out[],
820 size_t out_len,
821 const char* passphrase,
822 const uint8_t salt[],
823 size_t salt_len,
824 size_t N,
825 size_t r,
826 size_t p);
827
828/**
829* Derive a key
830* @param kdf_algo KDF algorithm, e.g., "SP800-56C"
831* @param out buffer holding the derived key, must be of length out_len
832* @param out_len the desired output length in bytes
833* @param secret the secret input
834* @param secret_len size of secret in bytes
835* @param salt a diversifier
836* @param salt_len size of salt in bytes
837* @param label purpose for the derived keying material
838* @param label_len size of label in bytes
839* @return 0 on success, a negative value on failure
840*/
842int botan_kdf(const char* kdf_algo,
843 uint8_t out[],
844 size_t out_len,
845 const uint8_t secret[],
846 size_t secret_len,
847 const uint8_t salt[],
848 size_t salt_len,
849 const uint8_t label[],
850 size_t label_len);
851
852/*
853* Raw Block Cipher (PRP) interface
854*/
855typedef struct botan_block_cipher_struct* botan_block_cipher_t;
856
857/**
858* Initialize a block cipher object
859*/
860BOTAN_FFI_EXPORT(2, 1) int botan_block_cipher_init(botan_block_cipher_t* bc, const char* cipher_name);
861
862/**
863* Destroy a block cipher object
864* @return 0 if success, error if invalid object handle
865*/
867
868/**
869* Reinitializes the block cipher
870* @return 0 on success, a negative value on failure
871*/
873
874/**
875* Set the key for a block cipher instance
876*/
877BOTAN_FFI_EXPORT(2, 1) int botan_block_cipher_set_key(botan_block_cipher_t bc, const uint8_t key[], size_t len);
878
879/**
880* Return the positive block size of this block cipher, or negative to
881* indicate an error
882*/
884
885/**
886* Encrypt one or more blocks with the cipher
887*/
889int botan_block_cipher_encrypt_blocks(botan_block_cipher_t bc, const uint8_t in[], uint8_t out[], size_t blocks);
890
891/**
892* Decrypt one or more blocks with the cipher
893*/
895int botan_block_cipher_decrypt_blocks(botan_block_cipher_t bc, const uint8_t in[], uint8_t out[], size_t blocks);
896
897/**
898* Get the name of this block cipher
899* @param cipher the object to read
900* @param name output buffer
901* @param name_len on input, the length of buffer, on success the number of bytes written
902*/
903BOTAN_FFI_EXPORT(2, 8) int botan_block_cipher_name(botan_block_cipher_t cipher, char* name, size_t* name_len);
904
905/**
906* Get the key length limits of this block cipher
907* @param cipher the object to read
908* @param out_minimum_keylength if non-NULL, will be set to minimum keylength of cipher
909* @param out_maximum_keylength if non-NULL, will be set to maximum keylength of cipher
910* @param out_keylength_modulo if non-NULL will be set to byte multiple of valid keys
911*/
914 size_t* out_minimum_keylength,
915 size_t* out_maximum_keylength,
916 size_t* out_keylength_modulo);
917
918/*
919* Multiple precision integers (MPI)
920*/
921typedef struct botan_mp_struct* botan_mp_t;
922
923/**
924* Initialize an MPI
925*/
927
928/**
929* Destroy (deallocate) an MPI
930* @return 0 if success, error if invalid object handle
931*/
933
934/**
935* Convert the MPI to a hex string. Writes up to botan_mp_num_bytes(mp)*2 + 5 bytes
936*
937* Prefer botan_mp_view_hex
938*/
939BOTAN_FFI_EXPORT(2, 1) int botan_mp_to_hex(botan_mp_t mp, char* out);
940
941/**
942* View the hex string encoding of the MPI.
943*/
945
946/**
947* Convert the MPI to a string. Currently radix == 10 and radix == 16 are supported.
948*/
949BOTAN_FFI_EXPORT(2, 1) int botan_mp_to_str(botan_mp_t mp, uint8_t radix, char* out, size_t* out_len);
950
951/**
952* View the MPI as a radix-N integer. Currently only radix 10 and radix 16 are supported
953*/
954BOTAN_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);
955
956/**
957* Set the MPI to zero
958*/
960
961/**
962* Set the MPI value from an int
963*/
964BOTAN_FFI_EXPORT(2, 1) int botan_mp_set_from_int(botan_mp_t mp, int initial_value);
965
966/**
967* Set the MPI value from another MP object
968*/
970
971/**
972* Set the MPI value from a string
973*/
974BOTAN_FFI_EXPORT(2, 1) int botan_mp_set_from_str(botan_mp_t dest, const char* str);
975
976/**
977* Set the MPI value from a string with arbitrary radix.
978* For arbitrary being 10 or 16.
979*/
980BOTAN_FFI_EXPORT(2, 1) int botan_mp_set_from_radix_str(botan_mp_t dest, const char* str, size_t radix);
981
982/**
983* Return the number of significant bits in the MPI
984*/
985BOTAN_FFI_EXPORT(2, 1) int botan_mp_num_bits(botan_mp_t n, size_t* bits);
986
987/**
988* Return the number of significant bytes in the MPI
989*/
990BOTAN_FFI_EXPORT(2, 1) int botan_mp_num_bytes(botan_mp_t n, size_t* bytes);
991
992/*
993* Convert the MPI to a big-endian binary string. Writes botan_mp_num_bytes to vec
994*
995* Note that the sign of the integer is ignored here; only the absolute value is copied
996*/
997BOTAN_FFI_EXPORT(2, 1) int botan_mp_to_bin(botan_mp_t mp, uint8_t vec[]);
998
999/*
1000* View the big-endian binary string encoding of this integer
1001*
1002* Note that the sign of the integer is ignored here; only the absolute value is viewed
1003*/
1005
1006/*
1007* Set an MP to the big-endian binary value
1008*/
1009BOTAN_FFI_EXPORT(2, 1) int botan_mp_from_bin(botan_mp_t mp, const uint8_t vec[], size_t vec_len);
1010
1011/*
1012* Convert the MPI to a uint32_t, if possible. Fails if MPI is negative or too large.
1013*/
1014BOTAN_FFI_EXPORT(2, 1) int botan_mp_to_uint32(botan_mp_t mp, uint32_t* val);
1015
1016/**
1017* This function should have been named mp_is_non_negative. Returns 1
1018* iff mp is greater than *or equal to* zero. Use botan_mp_is_negative
1019* to detect negative numbers, botan_mp_is_zero to check for zero.
1020*/
1022
1023/**
1024* Return 1 iff mp is less than 0
1025*/
1027
1029
1031
1032BOTAN_FFI_DEPRECATED("Use botan_mp_get_bit(0)") BOTAN_FFI_EXPORT(2, 1) int botan_mp_is_odd(botan_mp_t mp);
1033BOTAN_FFI_DEPRECATED("Use botan_mp_get_bit(0)") BOTAN_FFI_EXPORT(2, 1) int botan_mp_is_even(botan_mp_t mp);
1034
1035BOTAN_FFI_EXPORT(2, 8) int botan_mp_add_u32(botan_mp_t result, botan_mp_t x, uint32_t y);
1036BOTAN_FFI_EXPORT(2, 8) int botan_mp_sub_u32(botan_mp_t result, botan_mp_t x, uint32_t y);
1037
1041
1042BOTAN_FFI_EXPORT(2, 1)
1043int botan_mp_div(botan_mp_t quotient, botan_mp_t remainder, botan_mp_t x, botan_mp_t y);
1044
1045BOTAN_FFI_EXPORT(2, 1)
1047
1048/*
1049* Returns 0 if x != y
1050* Returns 1 if x == y
1051* Returns negative number on error
1052*/
1054
1055/*
1056* Sets *result to comparison result:
1057* -1 if x < y, 0 if x == y, 1 if x > y
1058* Returns negative number on error or zero on success
1059*/
1060BOTAN_FFI_EXPORT(2, 1) int botan_mp_cmp(int* result, botan_mp_t x, botan_mp_t y);
1061
1062/*
1063* Swap two botan_mp_t
1064*/
1066
1067/* Return (base^exponent) % modulus */
1068BOTAN_FFI_EXPORT(2, 1)
1069int botan_mp_powmod(botan_mp_t out, botan_mp_t base, botan_mp_t exponent, botan_mp_t modulus);
1070
1071BOTAN_FFI_EXPORT(2, 1) int botan_mp_lshift(botan_mp_t out, botan_mp_t in, size_t shift);
1072BOTAN_FFI_EXPORT(2, 1) int botan_mp_rshift(botan_mp_t out, botan_mp_t in, size_t shift);
1073
1075
1076BOTAN_FFI_EXPORT(2, 1) int botan_mp_rand_bits(botan_mp_t rand_out, botan_rng_t rng, size_t bits);
1077
1078BOTAN_FFI_EXPORT(2, 1)
1079int botan_mp_rand_range(botan_mp_t rand_out, botan_rng_t rng, botan_mp_t lower_bound, botan_mp_t upper_bound);
1080
1082
1083/**
1084* Returns 0 if n is not prime
1085* Returns 1 if n is prime
1086* Returns negative number on error
1087*/
1088BOTAN_FFI_EXPORT(2, 1) int botan_mp_is_prime(botan_mp_t n, botan_rng_t rng, size_t test_prob);
1089
1090/**
1091* Returns 0 if specified bit of n is not set
1092* Returns 1 if specified bit of n is set
1093* Returns negative number on error
1094*/
1095BOTAN_FFI_EXPORT(2, 1) int botan_mp_get_bit(botan_mp_t n, size_t bit);
1096
1097/**
1098* Set the specified bit
1099*/
1100BOTAN_FFI_EXPORT(2, 1) int botan_mp_set_bit(botan_mp_t n, size_t bit);
1101
1102/**
1103* Clear the specified bit
1104*/
1105BOTAN_FFI_EXPORT(2, 1) int botan_mp_clear_bit(botan_mp_t n, size_t bit);
1106
1107/* Bcrypt password hashing */
1108
1109/**
1110* Create a password hash using Bcrypt
1111* @param out buffer holding the password hash, should be of length 64 bytes
1112* @param out_len the desired output length in bytes
1113* @param password the password
1114* @param rng a random number generator
1115* @param work_factor how much work to do to slow down guessing attacks
1116* @param flags should be 0 in current API revision, all other uses are reserved
1117* and return BOTAN_FFI_ERROR_BAD_FLAG
1118* @return 0 on success, a negative value on failure
1119*
1120* Output is formatted bcrypt $2a$...
1121*
1122* TOD(Botan4) this should use char for the type of `out`
1123*/
1124BOTAN_FFI_EXPORT(2, 0)
1126 uint8_t* out, size_t* out_len, const char* password, botan_rng_t rng, size_t work_factor, uint32_t flags);
1127
1128/**
1129* Check a previously created password hash
1130* @param pass the password to check against
1131* @param hash the stored hash to check against
1132* @return 0 if if this password/hash combination is valid,
1133* 1 if the combination is not valid (but otherwise well formed),
1134* negative on error
1135*/
1136BOTAN_FFI_EXPORT(2, 0) int botan_bcrypt_is_valid(const char* pass, const char* hash);
1137
1138/*
1139* OIDs
1140*/
1141
1142typedef struct botan_asn1_oid_struct* botan_asn1_oid_t;
1143
1144/**
1145* @returns negative number on error, or zero on success
1146*/
1148
1149/**
1150* Create an OID from a string, either dot notation (e.g. '1.2.3.4') or a registered name (e.g. 'RSA')
1151* @param oid handle to the resulting OID
1152* @param oid_str the name of the OID to create
1153* @returns negative number on error, or zero on success
1154*/
1155BOTAN_FFI_EXPORT(3, 8) int botan_oid_from_string(botan_asn1_oid_t* oid, const char* oid_str);
1156
1157/**
1158* Registers an OID so that it may later be retrieved by name
1159* @returns negative number on error, or zero on success
1160*/
1161BOTAN_FFI_EXPORT(3, 8) int botan_oid_register(botan_asn1_oid_t oid, const char* name);
1162
1163/**
1164* View an OID in dot notation
1165*/
1167
1168/**
1169* View an OIDs registered name if it exists, else its dot notation
1170*/
1172
1173/**
1174* @returns 0 if a != b
1175* @returns 1 if a == b
1176* @returns negative number on error
1177*/
1179
1180/**
1181* Sets @param result to comparison result:
1182* -1 if a < b, 0 if a == b, 1 if a > b
1183* @returns negative number on error or zero on success
1184*/
1186
1187/*
1188* EC Groups
1189*/
1190
1191typedef struct botan_ec_group_struct* botan_ec_group_t;
1192
1193/**
1194* @returns negative number on error, or zero on success
1195*/
1197
1198/**
1199* Checks if in this build configuration it is possible to register an application specific elliptic curve and sets
1200* @param out to 1 if so, 0 otherwise
1201* @returns 0 on success, a negative value on failure
1202*/
1204
1205/**
1206* Checks if in this build configuration botan_ec_group_from_name(group_ptr, name) will succeed and sets
1207* @param out to 1 if so, 0 otherwise.
1208* @returns negative number on error, or zero on success
1209*/
1210BOTAN_FFI_EXPORT(3, 8) int botan_ec_group_supports_named_group(const char* name, int* out);
1211
1212/**
1213* Create a new EC Group from parameters
1214* @warning use only elliptic curve parameters that you trust
1215*
1216* @param ec_group the new object will be placed here
1217* @param p the elliptic curve prime (at most 521 bits)
1218* @param a the elliptic curve a param
1219* @param b the elliptic curve b param
1220* @param base_x the x coordinate of the group generator
1221* @param base_y the y coordinate of the group generator
1222* @param order the order of the group
1223* @returns negative number on error, or zero on success
1224*/
1225BOTAN_FFI_EXPORT(3, 8)
1227 botan_asn1_oid_t oid,
1228 botan_mp_t p,
1229 botan_mp_t a,
1230 botan_mp_t b,
1231 botan_mp_t base_x,
1232 botan_mp_t base_y,
1233 botan_mp_t order);
1234
1235/**
1236* Decode a BER encoded ECC domain parameter set
1237* @param ec_group the new object will be placed here
1238* @param ber encoding
1239* @param ber_len size of the encoding in bytes
1240* @returns negative number on error, or zero on success
1241*/
1242BOTAN_FFI_EXPORT(3, 8) int botan_ec_group_from_ber(botan_ec_group_t* ec_group, const uint8_t* ber, size_t ber_len);
1243
1244/**
1245* Initialize an EC Group from the PEM/ASN.1 encoding
1246* @param ec_group the new object will be placed here
1247* @param pem encoding
1248* @returns negative number on error, or zero on success
1249*/
1250BOTAN_FFI_EXPORT(3, 8) int botan_ec_group_from_pem(botan_ec_group_t* ec_group, const char* pem);
1251
1252/**
1253* Initialize an EC Group from a group named by an object identifier
1254* @param ec_group the new object will be placed here
1255* @param oid a known OID
1256* @returns negative number on error, or zero on success
1257*/
1259
1260/**
1261* Initialize an EC Group from a common group name (eg "secp256r1")
1262* @param ec_group the new object will be placed here
1263* @param name a known group name
1264* @returns negative number on error, or zero on success
1265*/
1266BOTAN_FFI_EXPORT(3, 8) int botan_ec_group_from_name(botan_ec_group_t* ec_group, const char* name);
1267
1268/**
1269* View an EC Group in DER encoding
1270*/
1271BOTAN_FFI_EXPORT(3, 8)
1273
1274/**
1275* View an EC Group in PEM encoding
1276*/
1277BOTAN_FFI_EXPORT(3, 8)
1279
1280/**
1281* Get the curve OID of an EC Group
1282*/
1284
1285/**
1286* Get the prime modulus of the field
1287*/
1289
1290/**
1291* Get the a parameter of the elliptic curve equation
1292*/
1294
1295/**
1296* Get the b parameter of the elliptic curve equation
1297*/
1299
1300/**
1301* Get the x coordinate of the base point
1302*/
1304
1305/**
1306* Get the y coordinate of the base point
1307*/
1309
1310/**
1311* Get the order of the base point
1312*/
1314
1315/**
1316* @returns 0 if curve1 != curve2
1317* @returns 1 if curve1 == curve2
1318* @returns negative number on error
1319*/
1321
1322/*
1323* Public/private key creation, import, ...
1324*/
1325typedef struct botan_privkey_struct* botan_privkey_t;
1326
1327/**
1328* Create a new private key
1329* @param key the new object will be placed here
1330* @param algo_name something like "RSA" or "ECDSA"
1331* @param algo_params is specific to the algorithm. For RSA, specifies
1332* the modulus bit length. For ECC is the name of the curve.
1333* @param rng a random number generator
1334*/
1335BOTAN_FFI_EXPORT(2, 0)
1336int botan_privkey_create(botan_privkey_t* key, const char* algo_name, const char* algo_params, botan_rng_t rng);
1337
1338/**
1339* Create a new ec private key
1340* @param key the new object will be placed here
1341* @param algo_name something like "ECDSA" or "ECDH"
1342* @param ec_group a (possibly application specific) elliptic curve
1343* @param rng a random number generator
1344*/
1345BOTAN_FFI_EXPORT(3, 8)
1346int botan_ec_privkey_create(botan_privkey_t* key, const char* algo_name, botan_ec_group_t ec_group, botan_rng_t rng);
1347
1348#define BOTAN_CHECK_KEY_EXPENSIVE_TESTS 1
1349
1350BOTAN_FFI_EXPORT(2, 0) int botan_privkey_check_key(botan_privkey_t key, botan_rng_t rng, uint32_t flags);
1351
1352BOTAN_FFI_DEPRECATED("Use botan_privkey_create")
1353BOTAN_FFI_EXPORT(2, 0) int botan_privkey_create_rsa(botan_privkey_t* key, botan_rng_t rng, size_t n_bits);
1354BOTAN_FFI_DEPRECATED("Use botan_privkey_create")
1355BOTAN_FFI_EXPORT(2, 0) int botan_privkey_create_ecdsa(botan_privkey_t* key, botan_rng_t rng, const char* params);
1356BOTAN_FFI_DEPRECATED("Use botan_privkey_create")
1357BOTAN_FFI_EXPORT(2, 0) int botan_privkey_create_ecdh(botan_privkey_t* key, botan_rng_t rng, const char* params);
1358BOTAN_FFI_DEPRECATED("Use botan_privkey_create")
1359BOTAN_FFI_EXPORT(2, 0) int botan_privkey_create_mceliece(botan_privkey_t* key, botan_rng_t rng, size_t n, size_t t);
1360BOTAN_FFI_DEPRECATED("Use botan_privkey_create")
1361BOTAN_FFI_EXPORT(2, 0) int botan_privkey_create_dh(botan_privkey_t* key, botan_rng_t rng, const char* param);
1362
1363/**
1364 * Generates DSA key pair. Gives to a caller control over key length
1365 * and order of a subgroup 'q'.
1366 *
1367 * @param key handler to the resulting key
1368 * @param rng initialized PRNG
1369 * @param pbits length of the key in bits. Must be between in range (1024, 3072)
1370 * and multiple of 64. Bit size of the prime 'p'
1371 * @param qbits order of the subgroup. Must be in range (160, 256) and multiple
1372 * of 8
1373 *
1374 * @returns BOTAN_FFI_SUCCESS Success, `key' initialized with DSA key
1375 * @returns BOTAN_FFI_ERROR_NULL_POINTER either `key' or `rng' is NULL
1376 * @returns BOTAN_FFI_ERROR_BAD_PARAMETER unexpected value for either `pbits' or
1377 * `qbits'
1378 * @returns BOTAN_FFI_ERROR_NOT_IMPLEMENTED functionality not implemented
1379 *
1380*/
1381BOTAN_FFI_EXPORT(2, 5) int botan_privkey_create_dsa(botan_privkey_t* key, botan_rng_t rng, size_t pbits, size_t qbits);
1382
1383/**
1384 * Generates ElGamal key pair. Caller has a control over key length
1385 * and order of a subgroup 'q'. Function is able to use two types of
1386 * primes:
1387 * * if pbits-1 == qbits then safe primes are used for key generation
1388 * * otherwise generation uses group of prime order
1389 *
1390 * @param key handler to the resulting key
1391 * @param rng initialized PRNG
1392 * @param pbits length of the key in bits. Must be at least 1024
1393 * @param qbits order of the subgroup. Must be at least 160
1394 *
1395 * @returns BOTAN_FFI_SUCCESS Success, `key' initialized with DSA key
1396 * @returns BOTAN_FFI_ERROR_NULL_POINTER either `key' or `rng' is NULL
1397 * @returns BOTAN_FFI_ERROR_BAD_PARAMETER unexpected value for either `pbits' or
1398 * `qbits'
1399 * @returns BOTAN_FFI_ERROR_NOT_IMPLEMENTED functionality not implemented
1400 *
1401*/
1402BOTAN_FFI_EXPORT(2, 5)
1403int botan_privkey_create_elgamal(botan_privkey_t* key, botan_rng_t rng, size_t pbits, size_t qbits);
1404
1405/**
1406* Input currently assumed to be PKCS #8 structure;
1407* Set password to NULL to indicate no encryption expected
1408* Starting in 2.8.0, the rng parameter is unused and may be set to null
1409*/
1410BOTAN_FFI_EXPORT(2, 0)
1411int botan_privkey_load(botan_privkey_t* key, botan_rng_t rng, const uint8_t bits[], size_t len, const char* password);
1412
1413/**
1414* @return 0 if success, error if invalid object handle
1415*/
1417
1418#define BOTAN_PRIVKEY_EXPORT_FLAG_DER 0
1419#define BOTAN_PRIVKEY_EXPORT_FLAG_PEM 1
1420#define BOTAN_PRIVKEY_EXPORT_FLAG_RAW 2
1421
1422/**
1423* On input *out_len is number of bytes in out[]
1424* On output *out_len is number of bytes written (or required)
1425* If out is not big enough no output is written, *out_len is set and 1 is returned
1426* Returns 0 on success and sets
1427* If some other error occurs a negative integer is returned.
1428*/
1429BOTAN_FFI_DEPRECATED("Use botan_privkey_view_{der,pem,raw}")
1430BOTAN_FFI_EXPORT(2, 0) int botan_privkey_export(botan_privkey_t key, uint8_t out[], size_t* out_len, uint32_t flags);
1431
1432/**
1433* View the private key's DER encoding
1434*/
1436
1437/**
1438* View the private key's PEM encoding
1439*/
1441
1442/**
1443* View the private key's raw encoding
1444*/
1446
1447BOTAN_FFI_EXPORT(2, 8) int botan_privkey_algo_name(botan_privkey_t key, char out[], size_t* out_len);
1448
1449/**
1450* Set encryption_algo to NULL or "" to have the library choose a default (recommended)
1451*/
1452BOTAN_FFI_DEPRECATED("Use botan_privkey_export_encrypted_pbkdf_{msec,iter}")
1453BOTAN_FFI_EXPORT(2, 0)
1455 uint8_t out[],
1456 size_t* out_len,
1457 botan_rng_t rng,
1458 const char* passphrase,
1459 const char* encryption_algo,
1460 uint32_t flags);
1461
1462/*
1463* Export a private key, running PBKDF for specified amount of time
1464* @param key the private key to export
1465*
1466* Note: starting in 3.0, the output iterations count is not provided
1467*/
1468BOTAN_FFI_DEPRECATED("Use botan_privkey_view_encrypted_{der,pem}_timed")
1469BOTAN_FFI_EXPORT(2, 0)
1471 uint8_t out[],
1472 size_t* out_len,
1473 botan_rng_t rng,
1474 const char* passphrase,
1475 uint32_t pbkdf_msec_runtime,
1476 size_t* pbkdf_iterations_out,
1477 const char* cipher_algo,
1478 const char* pbkdf_algo,
1479 uint32_t flags);
1480
1481/**
1482* Export a private key using the specified number of iterations.
1483*/
1484BOTAN_FFI_DEPRECATED("Use botan_privkey_view_encrypted_{der,pem}")
1485BOTAN_FFI_EXPORT(2, 0)
1487 uint8_t out[],
1488 size_t* out_len,
1489 botan_rng_t rng,
1490 const char* passphrase,
1491 size_t pbkdf_iterations,
1492 const char* cipher_algo,
1493 const char* pbkdf_algo,
1494 uint32_t flags);
1495
1496/**
1497* View the encryption of a private key (binary DER encoding)
1498*
1499* Set cipher_algo, pbkdf_algo to NULL to use defaults
1500* Set pbkdf_iterations to 0 to use defaults
1501*/
1502BOTAN_FFI_EXPORT(3, 0)
1504 botan_rng_t rng,
1505 const char* passphrase,
1506 const char* cipher_algo,
1507 const char* pbkdf_algo,
1508 size_t pbkdf_iterations,
1509 botan_view_ctx ctx,
1510 botan_view_bin_fn view);
1511
1512/**
1513* View the encryption of a private key (binary DER encoding)
1514*
1515* Set cipher_algo, pbkdf_algo to NULL to use defaults
1516*/
1517BOTAN_FFI_EXPORT(3, 0)
1519 botan_rng_t rng,
1520 const char* passphrase,
1521 const char* cipher_algo,
1522 const char* pbkdf_algo,
1523 size_t pbkdf_runtime_msec,
1524 botan_view_ctx ctx,
1525 botan_view_bin_fn view);
1526
1527/**
1528* View the encryption of a private key (PEM encoding)
1529*
1530* Set cipher_algo, pbkdf_algo to NULL to use defaults
1531* Set pbkdf_iterations to 0 to use defaults
1532*/
1533BOTAN_FFI_EXPORT(3, 0)
1535 botan_rng_t rng,
1536 const char* passphrase,
1537 const char* cipher_algo,
1538 const char* pbkdf_algo,
1539 size_t pbkdf_iterations,
1540 botan_view_ctx ctx,
1541 botan_view_str_fn view);
1542
1543/**
1544* View the encryption of a private key (PEM encoding)
1545*
1546* Set cipher_algo, pbkdf_algo to NULL to use defaults
1547*/
1548BOTAN_FFI_EXPORT(3, 0)
1550 botan_rng_t rng,
1551 const char* passphrase,
1552 const char* cipher_algo,
1553 const char* pbkdf_algo,
1554 size_t pbkdf_runtime_msec,
1555 botan_view_ctx ctx,
1556 botan_view_str_fn view);
1557
1558typedef struct botan_pubkey_struct* botan_pubkey_t;
1559
1560BOTAN_FFI_EXPORT(2, 0) int botan_pubkey_load(botan_pubkey_t* key, const uint8_t bits[], size_t len);
1561
1563
1564BOTAN_FFI_DEPRECATED("Use botan_pubkey_view_{der,pem,raw}")
1565BOTAN_FFI_EXPORT(2, 0) int botan_pubkey_export(botan_pubkey_t key, uint8_t out[], size_t* out_len, uint32_t flags);
1566
1567/**
1568* View the public key's DER encoding
1569*/
1571
1572/**
1573* View the public key's PEM encoding
1574*/
1576
1577/**
1578* View the public key's raw encoding
1579*/
1581
1582BOTAN_FFI_EXPORT(2, 0) int botan_pubkey_algo_name(botan_pubkey_t key, char out[], size_t* out_len);
1583
1584/**
1585* Returns 0 if key is valid, negative if invalid key or some other error
1586*/
1587BOTAN_FFI_EXPORT(2, 0) int botan_pubkey_check_key(botan_pubkey_t key, botan_rng_t rng, uint32_t flags);
1588
1589BOTAN_FFI_EXPORT(2, 0) int botan_pubkey_estimated_strength(botan_pubkey_t key, size_t* estimate);
1590
1591BOTAN_FFI_EXPORT(2, 0)
1592int botan_pubkey_fingerprint(botan_pubkey_t key, const char* hash, uint8_t out[], size_t* out_len);
1593
1594/**
1595* @return 0 if success, error if invalid object handle
1596*/
1598
1599/*
1600* Get arbitrary named fields from public or private keys
1601*/
1602BOTAN_FFI_EXPORT(2, 0) int botan_pubkey_get_field(botan_mp_t output, botan_pubkey_t key, const char* field_name);
1603
1604BOTAN_FFI_EXPORT(2, 0) int botan_privkey_get_field(botan_mp_t output, botan_privkey_t key, const char* field_name);
1605
1606/*
1607* Get the OID from public or private keys
1608*/
1609BOTAN_FFI_EXPORT(3, 8)
1611
1612BOTAN_FFI_EXPORT(3, 8)
1614
1615/**
1616* Checks whether a key is stateful and sets
1617* @param out to 1 if it is, or 0 if the key is not stateful
1618* @return 0 on success, a negative value on failure
1619*/
1621
1622/**
1623* Gets information on many operations a (stateful) key has remaining and sets
1624* @param out to that value
1625* @return 0 on success, a negative value on failure or if the key is not stateful
1626*/
1628
1629/*
1630* Algorithm specific key operations: RSA
1631*/
1633
1634BOTAN_FFI_EXPORT(2, 8) int botan_privkey_load_rsa_pkcs1(botan_privkey_t* key, const uint8_t bits[], size_t len);
1635
1636BOTAN_FFI_DEPRECATED("Use botan_privkey_get_field")
1638BOTAN_FFI_DEPRECATED("Use botan_privkey_get_field")
1640BOTAN_FFI_DEPRECATED("Use botan_privkey_get_field")
1642BOTAN_FFI_DEPRECATED("Use botan_privkey_get_field")
1644BOTAN_FFI_DEPRECATED("Use botan_privkey_get_field")
1646
1647BOTAN_FFI_EXPORT(2, 8)
1648int botan_privkey_rsa_get_privkey(botan_privkey_t rsa_key, uint8_t out[], size_t* out_len, uint32_t flags);
1649
1651
1652BOTAN_FFI_DEPRECATED("Use botan_pubkey_get_field")
1654BOTAN_FFI_DEPRECATED("Use botan_pubkey_get_field")
1656
1657/*
1658* Algorithm specific key operations: DSA
1659*/
1660BOTAN_FFI_EXPORT(2, 0)
1662
1663BOTAN_FFI_EXPORT(2, 0)
1665
1666BOTAN_FFI_DEPRECATED("Use botan_privkey_get_field")
1668
1669BOTAN_FFI_DEPRECATED("Use botan_pubkey_get_field")
1671BOTAN_FFI_DEPRECATED("Use botan_pubkey_get_field")
1673BOTAN_FFI_DEPRECATED("Use botan_pubkey_get_field")
1675BOTAN_FFI_DEPRECATED("Use botan_pubkey_get_field")
1677
1678/*
1679* Loads Diffie Hellman private key
1680*
1681* @param key variable populated with key material
1682* @param p prime order of a Z_p group
1683* @param g group generator
1684* @param x private key
1685*
1686* @pre key is NULL on input
1687* @post function allocates memory and assigns to `key'
1688*
1689* @return 0 on success, a negative value on failure
1690*/
1692/**
1693* Loads Diffie Hellman public key
1694*
1695* @param key variable populated with key material
1696* @param p prime order of a Z_p group
1697* @param g group generator
1698* @param y public key
1699*
1700* @pre key is NULL on input
1701* @post function allocates memory and assigns to `key'
1702*
1703* @return 0 on success, a negative value on failure
1704*/
1706
1707/*
1708* Algorithm specific key operations: ElGamal
1709*/
1710
1711/**
1712* Loads ElGamal public key
1713* @param key variable populated with key material
1714* @param p prime order of a Z_p group
1715* @param g group generator
1716* @param y public key
1717*
1718* @pre key is NULL on input
1719* @post function allocates memory and assigns to `key'
1720*
1721* @return 0 on success, a negative value on failure
1722*/
1724
1725/**
1726* Loads ElGamal private key
1727*
1728* @param key variable populated with key material
1729* @param p prime order of a Z_p group
1730* @param g group generator
1731* @param x private key
1732*
1733* @pre key is NULL on input
1734* @post function allocates memory and assigns to `key'
1735*
1736* @return 0 on success, a negative value on failure
1737*/
1739
1740/*
1741* Algorithm specific key operations: Ed25519
1742*/
1743
1744BOTAN_FFI_EXPORT(2, 2) int botan_privkey_load_ed25519(botan_privkey_t* key, const uint8_t privkey[32]);
1745
1746BOTAN_FFI_EXPORT(2, 2) int botan_pubkey_load_ed25519(botan_pubkey_t* key, const uint8_t pubkey[32]);
1747
1748BOTAN_FFI_DEPRECATED("Use botan_privkey_view_raw")
1749BOTAN_FFI_EXPORT(2, 2) int botan_privkey_ed25519_get_privkey(botan_privkey_t key, uint8_t output[64]);
1750
1751BOTAN_FFI_DEPRECATED("Use botan_pubkey_view_raw")
1752BOTAN_FFI_EXPORT(2, 2) int botan_pubkey_ed25519_get_pubkey(botan_pubkey_t key, uint8_t pubkey[32]);
1753
1754/*
1755* Algorithm specific key operations: Ed448
1756*/
1757
1758BOTAN_FFI_EXPORT(3, 4) int botan_privkey_load_ed448(botan_privkey_t* key, const uint8_t privkey[57]);
1759
1760BOTAN_FFI_EXPORT(3, 4) int botan_pubkey_load_ed448(botan_pubkey_t* key, const uint8_t pubkey[57]);
1761
1762BOTAN_FFI_DEPRECATED("Use botan_privkey_view_raw")
1763BOTAN_FFI_EXPORT(3, 4) int botan_privkey_ed448_get_privkey(botan_privkey_t key, uint8_t output[57]);
1764
1765BOTAN_FFI_DEPRECATED("Use botan_pubkey_view_raw")
1766BOTAN_FFI_EXPORT(3, 4) int botan_pubkey_ed448_get_pubkey(botan_pubkey_t key, uint8_t pubkey[57]);
1767
1768/*
1769* Algorithm specific key operations: X25519
1770*/
1771
1772BOTAN_FFI_EXPORT(2, 8) int botan_privkey_load_x25519(botan_privkey_t* key, const uint8_t privkey[32]);
1773
1774BOTAN_FFI_EXPORT(2, 8) int botan_pubkey_load_x25519(botan_pubkey_t* key, const uint8_t pubkey[32]);
1775
1776BOTAN_FFI_DEPRECATED("Use botan_privkey_view_raw")
1777BOTAN_FFI_EXPORT(2, 8) int botan_privkey_x25519_get_privkey(botan_privkey_t key, uint8_t output[32]);
1778
1779BOTAN_FFI_DEPRECATED("Use botan_pubkey_view_raw")
1780BOTAN_FFI_EXPORT(2, 8) int botan_pubkey_x25519_get_pubkey(botan_pubkey_t key, uint8_t pubkey[32]);
1781
1782/*
1783* Algorithm specific key operations: X448
1784*/
1785
1786BOTAN_FFI_EXPORT(3, 4) int botan_privkey_load_x448(botan_privkey_t* key, const uint8_t privkey[56]);
1787
1788BOTAN_FFI_EXPORT(3, 4) int botan_pubkey_load_x448(botan_pubkey_t* key, const uint8_t pubkey[56]);
1789
1790BOTAN_FFI_DEPRECATED("Use botan_privkey_view_raw")
1791BOTAN_FFI_EXPORT(3, 4) int botan_privkey_x448_get_privkey(botan_privkey_t key, uint8_t output[56]);
1792
1793BOTAN_FFI_DEPRECATED("Use botan_pubkey_view_raw")
1794BOTAN_FFI_EXPORT(3, 4) int botan_pubkey_x448_get_pubkey(botan_pubkey_t key, uint8_t pubkey[56]);
1795
1796/*
1797* Algorithm specific key operations: ML-DSA
1798*/
1799
1800BOTAN_FFI_EXPORT(3, 6)
1801int botan_privkey_load_ml_dsa(botan_privkey_t* key, const uint8_t privkey[], size_t key_len, const char* mldsa_mode);
1802
1803BOTAN_FFI_EXPORT(3, 6)
1804int botan_pubkey_load_ml_dsa(botan_pubkey_t* key, const uint8_t pubkey[], size_t key_len, const char* mldsa_mode);
1805
1806/*
1807* Algorithm specific key operations: Kyber R3
1808*
1809* Note that Kyber R3 support is somewhat deprecated and may be removed in a
1810* future major release. Using the final ML-KEM is highly recommended in any new
1811* system.
1812*/
1813
1814BOTAN_FFI_DEPRECATED("Kyber R3 support is deprecated")
1815BOTAN_FFI_EXPORT(3, 1) int botan_privkey_load_kyber(botan_privkey_t* key, const uint8_t privkey[], size_t key_len);
1816
1817BOTAN_FFI_DEPRECATED("Kyber R3 support is deprecated")
1818BOTAN_FFI_EXPORT(3, 1) int botan_pubkey_load_kyber(botan_pubkey_t* key, const uint8_t pubkey[], size_t key_len);
1819
1820BOTAN_FFI_DEPRECATED("Use generic botan_privkey_view_raw")
1821BOTAN_FFI_EXPORT(3, 1)
1823
1824BOTAN_FFI_DEPRECATED("Use generic botan_pubkey_view_raw")
1825BOTAN_FFI_EXPORT(3, 1)
1827
1828/**
1829* Algorithm specific key operation: FrodoKEM
1830*/
1831
1832BOTAN_FFI_EXPORT(3, 6)
1833int botan_privkey_load_frodokem(botan_privkey_t* key, const uint8_t privkey[], size_t key_len, const char* frodo_mode);
1834
1835BOTAN_FFI_EXPORT(3, 6)
1836int botan_pubkey_load_frodokem(botan_pubkey_t* key, const uint8_t pubkey[], size_t key_len, const char* frodo_mode);
1837
1838/**
1839* Algorithm specific key operation: Classic McEliece
1840*/
1841
1842BOTAN_FFI_EXPORT(3, 6)
1844 const uint8_t privkey[],
1845 size_t key_len,
1846 const char* cmce_mode);
1847
1848BOTAN_FFI_EXPORT(3, 6)
1850 const uint8_t pubkey[],
1851 size_t key_len,
1852 const char* cmce_mode);
1853
1854/*
1855* Algorithm specific key operations: ML-KEM
1856*/
1857
1858BOTAN_FFI_EXPORT(3, 6)
1859int botan_privkey_load_ml_kem(botan_privkey_t* key, const uint8_t privkey[], size_t key_len, const char* mlkem_mode);
1860
1861BOTAN_FFI_EXPORT(3, 6)
1862int botan_pubkey_load_ml_kem(botan_pubkey_t* key, const uint8_t pubkey[], size_t key_len, const char* mlkem_mode);
1863
1864/*
1865* Algorithm specific key operations: SLH-DSA
1866*/
1867
1868BOTAN_FFI_EXPORT(3, 6)
1869int botan_privkey_load_slh_dsa(botan_privkey_t* key, const uint8_t privkey[], size_t key_len, const char* slhdsa_mode);
1870
1871BOTAN_FFI_EXPORT(3, 6)
1872int botan_pubkey_load_slh_dsa(botan_pubkey_t* key, const uint8_t pubkey[], size_t key_len, const char* slhdsa_mode);
1873
1874/*
1875* Algorithm specific key operations: ECDSA and ECDH
1876*/
1877BOTAN_FFI_EXPORT(3, 2)
1879
1880BOTAN_FFI_EXPORT(2, 2)
1881int botan_privkey_load_ecdsa(botan_privkey_t* key, botan_mp_t scalar, const char* curve_name);
1882
1883BOTAN_FFI_EXPORT(2, 2)
1884int botan_pubkey_load_ecdsa(botan_pubkey_t* key, botan_mp_t public_x, botan_mp_t public_y, const char* curve_name);
1885
1886BOTAN_FFI_EXPORT(3, 10)
1887int botan_pubkey_load_ecdsa_sec1(botan_pubkey_t* key, const uint8_t sec1[], size_t sec1_len, const char* curve_name);
1888
1889BOTAN_FFI_EXPORT(2, 2)
1890int botan_pubkey_load_ecdh(botan_pubkey_t* key, botan_mp_t public_x, botan_mp_t public_y, const char* curve_name);
1891
1892BOTAN_FFI_EXPORT(3, 10)
1893int botan_pubkey_load_ecdh_sec1(botan_pubkey_t* key, const uint8_t sec1[], size_t sec1_len, const char* curve_name);
1894
1895BOTAN_FFI_EXPORT(2, 2)
1896int botan_privkey_load_ecdh(botan_privkey_t* key, botan_mp_t scalar, const char* curve_name);
1897
1898BOTAN_FFI_EXPORT(2, 2)
1899int botan_pubkey_load_sm2(botan_pubkey_t* key, botan_mp_t public_x, botan_mp_t public_y, const char* curve_name);
1900
1901BOTAN_FFI_EXPORT(3, 10)
1902int botan_pubkey_load_sm2_sec1(botan_pubkey_t* key, const uint8_t sec1[], size_t sec1_len, const char* curve_name);
1903
1904BOTAN_FFI_EXPORT(2, 2)
1905int botan_privkey_load_sm2(botan_privkey_t* key, botan_mp_t scalar, const char* curve_name);
1906
1907BOTAN_FFI_DEPRECATED("Use botan_pubkey_load_sm2")
1908BOTAN_FFI_EXPORT(2, 2)
1909int botan_pubkey_load_sm2_enc(botan_pubkey_t* key, botan_mp_t public_x, botan_mp_t public_y, const char* curve_name);
1910
1911BOTAN_FFI_DEPRECATED("Use botan_privkey_load_sm2")
1912BOTAN_FFI_EXPORT(2, 2)
1913int botan_privkey_load_sm2_enc(botan_privkey_t* key, botan_mp_t scalar, const char* curve_name);
1914
1915BOTAN_FFI_EXPORT(2, 3)
1917 uint8_t out[], size_t* out_len, const char* ident, const char* hash_algo, botan_pubkey_t key);
1918
1919/**
1920* View the uncompressed public point associated with the key
1921*/
1922BOTAN_FFI_EXPORT(3, 0)
1924
1925/*
1926* Public Key Encryption
1927*/
1928typedef struct botan_pk_op_encrypt_struct* botan_pk_op_encrypt_t;
1929
1930BOTAN_FFI_EXPORT(2, 0)
1931int botan_pk_op_encrypt_create(botan_pk_op_encrypt_t* op, botan_pubkey_t key, const char* padding, uint32_t flags);
1932
1933/**
1934* @return 0 if success, error if invalid object handle
1935*/
1937
1938BOTAN_FFI_EXPORT(2, 8)
1939int botan_pk_op_encrypt_output_length(botan_pk_op_encrypt_t op, size_t ptext_len, size_t* ctext_len);
1940
1941BOTAN_FFI_EXPORT(2, 0)
1943 botan_rng_t rng,
1944 uint8_t out[],
1945 size_t* out_len,
1946 const uint8_t plaintext[],
1947 size_t plaintext_len);
1948
1949/*
1950* Public Key Decryption
1951*/
1952typedef struct botan_pk_op_decrypt_struct* botan_pk_op_decrypt_t;
1953
1954BOTAN_FFI_EXPORT(2, 0)
1955int botan_pk_op_decrypt_create(botan_pk_op_decrypt_t* op, botan_privkey_t key, const char* padding, uint32_t flags);
1956
1957/**
1958* @return 0 if success, error if invalid object handle
1959*/
1961
1962BOTAN_FFI_EXPORT(2, 8)
1963int botan_pk_op_decrypt_output_length(botan_pk_op_decrypt_t op, size_t ctext_len, size_t* ptext_len);
1964
1965BOTAN_FFI_EXPORT(2, 0)
1967 botan_pk_op_decrypt_t op, uint8_t out[], size_t* out_len, const uint8_t ciphertext[], size_t ciphertext_len);
1968
1969/*
1970* Signature Generation
1971*/
1972
1973#define BOTAN_PUBKEY_DER_FORMAT_SIGNATURE 1
1974
1975typedef struct botan_pk_op_sign_struct* botan_pk_op_sign_t;
1976
1977BOTAN_FFI_EXPORT(2, 0)
1978int botan_pk_op_sign_create(botan_pk_op_sign_t* op, botan_privkey_t key, const char* hash_and_padding, uint32_t flags);
1979
1980/**
1981* @return 0 if success, error if invalid object handle
1982*/
1984
1986
1987BOTAN_FFI_EXPORT(2, 0) int botan_pk_op_sign_update(botan_pk_op_sign_t op, const uint8_t in[], size_t in_len);
1988
1989BOTAN_FFI_EXPORT(2, 0)
1990int botan_pk_op_sign_finish(botan_pk_op_sign_t op, botan_rng_t rng, uint8_t sig[], size_t* sig_len);
1991
1992/*
1993* Signature Verification
1994*/
1995typedef struct botan_pk_op_verify_struct* botan_pk_op_verify_t;
1996
1997BOTAN_FFI_EXPORT(2, 0)
1999 botan_pubkey_t key,
2000 const char* hash_and_padding,
2001 uint32_t flags);
2002
2003/**
2004* @return 0 if success, error if invalid object handle
2005*/
2007
2008BOTAN_FFI_EXPORT(2, 0) int botan_pk_op_verify_update(botan_pk_op_verify_t op, const uint8_t in[], size_t in_len);
2009BOTAN_FFI_EXPORT(2, 0) int botan_pk_op_verify_finish(botan_pk_op_verify_t op, const uint8_t sig[], size_t sig_len);
2010
2011/*
2012* Key Agreement
2013*/
2014typedef struct botan_pk_op_ka_struct* botan_pk_op_ka_t;
2015
2016BOTAN_FFI_EXPORT(2, 0)
2017int botan_pk_op_key_agreement_create(botan_pk_op_ka_t* op, botan_privkey_t key, const char* kdf, uint32_t flags);
2018
2019/**
2020* @return 0 if success, error if invalid object handle
2021*/
2023
2024BOTAN_FFI_EXPORT(2, 0) int botan_pk_op_key_agreement_export_public(botan_privkey_t key, uint8_t out[], size_t* out_len);
2025
2026BOTAN_FFI_EXPORT(3, 0)
2028
2030
2031BOTAN_FFI_EXPORT(2, 0)
2033 uint8_t out[],
2034 size_t* out_len,
2035 const uint8_t other_key[],
2036 size_t other_key_len,
2037 const uint8_t salt[],
2038 size_t salt_len);
2039
2040/*
2041* Key Encapsulation
2042*/
2043typedef struct botan_pk_op_kem_encrypt_struct* botan_pk_op_kem_encrypt_t;
2044
2045BOTAN_FFI_EXPORT(3, 0)
2047
2048/**
2049* @return 0 if success, error if invalid object handle
2050*/
2052
2053BOTAN_FFI_EXPORT(3, 0)
2055 size_t desired_shared_key_length,
2056 size_t* output_shared_key_length);
2057
2058BOTAN_FFI_EXPORT(3, 0)
2060 size_t* output_encapsulated_key_length);
2061
2062BOTAN_FFI_EXPORT(3, 0)
2064 botan_rng_t rng,
2065 const uint8_t salt[],
2066 size_t salt_len,
2067 size_t desired_shared_key_len,
2068 uint8_t shared_key[],
2069 size_t* shared_key_len,
2070 uint8_t encapsulated_key[],
2071 size_t* encapsulated_key_len);
2072
2073typedef struct botan_pk_op_kem_decrypt_struct* botan_pk_op_kem_decrypt_t;
2074
2075BOTAN_FFI_EXPORT(3, 0)
2077
2078/**
2079* @return 0 if success, error if invalid object handle
2080*/
2082
2083BOTAN_FFI_EXPORT(3, 0)
2085 size_t desired_shared_key_length,
2086 size_t* output_shared_key_length);
2087
2088BOTAN_FFI_EXPORT(3, 0)
2090 const uint8_t salt[],
2091 size_t salt_len,
2092 const uint8_t encapsulated_key[],
2093 size_t encapsulated_key_len,
2094 size_t desired_shared_key_len,
2095 uint8_t shared_key[],
2096 size_t* shared_key_len);
2097
2098/**
2099* Signature Scheme Utility Functions
2100*/
2101
2102BOTAN_FFI_EXPORT(2, 0) int botan_pkcs_hash_id(const char* hash_name, uint8_t pkcs_id[], size_t* pkcs_id_len);
2103
2104/*
2105* Always returns BOTAN_FFI_ERROR_NOT_IMPLEMENTED
2106*/
2107BOTAN_FFI_DEPRECATED("No longer implemented")
2108BOTAN_FFI_EXPORT(2, 0)
2110 botan_rng_t rng,
2111 const char* aead,
2112 const uint8_t pt[],
2113 size_t pt_len,
2114 const uint8_t ad[],
2115 size_t ad_len,
2116 uint8_t ct[],
2117 size_t* ct_len);
2118
2119/*
2120* Always returns BOTAN_FFI_ERROR_NOT_IMPLEMENTED
2121*/
2122BOTAN_FFI_DEPRECATED("No longer implemented")
2123BOTAN_FFI_EXPORT(2, 0)
2125 const char* aead,
2126 const uint8_t ct[],
2127 size_t ct_len,
2128 const uint8_t ad[],
2129 size_t ad_len,
2130 uint8_t pt[],
2131 size_t* pt_len);
2132
2133/*
2134* X.509 certificates
2135**************************/
2136
2137typedef struct botan_x509_cert_struct* botan_x509_cert_t;
2138
2139BOTAN_FFI_EXPORT(2, 0) int botan_x509_cert_load(botan_x509_cert_t* cert_obj, const uint8_t cert[], size_t cert_len);
2140BOTAN_FFI_EXPORT(2, 0) int botan_x509_cert_load_file(botan_x509_cert_t* cert_obj, const char* filename);
2141
2142/**
2143* @return 0 if success, error if invalid object handle
2144*/
2146
2148
2149/* Prefer botan_x509_cert_not_before and botan_x509_cert_not_after */
2150BOTAN_FFI_EXPORT(2, 0) int botan_x509_cert_get_time_starts(botan_x509_cert_t cert, char out[], size_t* out_len);
2151BOTAN_FFI_EXPORT(2, 0) int botan_x509_cert_get_time_expires(botan_x509_cert_t cert, char out[], size_t* out_len);
2152
2153BOTAN_FFI_EXPORT(2, 8) int botan_x509_cert_not_before(botan_x509_cert_t cert, uint64_t* time_since_epoch);
2154BOTAN_FFI_EXPORT(2, 8) int botan_x509_cert_not_after(botan_x509_cert_t cert, uint64_t* time_since_epoch);
2155
2156/* TODO(Botan4) this should use char for the out param */
2157BOTAN_FFI_EXPORT(2, 0)
2158int botan_x509_cert_get_fingerprint(botan_x509_cert_t cert, const char* hash, uint8_t out[], size_t* out_len);
2159
2160BOTAN_FFI_EXPORT(2, 0) int botan_x509_cert_get_serial_number(botan_x509_cert_t cert, uint8_t out[], size_t* out_len);
2161BOTAN_FFI_EXPORT(2, 0) int botan_x509_cert_get_authority_key_id(botan_x509_cert_t cert, uint8_t out[], size_t* out_len);
2162BOTAN_FFI_EXPORT(2, 0) int botan_x509_cert_get_subject_key_id(botan_x509_cert_t cert, uint8_t out[], size_t* out_len);
2163
2164BOTAN_FFI_EXPORT(2, 0) int botan_x509_cert_get_public_key_bits(botan_x509_cert_t cert, uint8_t out[], size_t* out_len);
2165
2166BOTAN_FFI_EXPORT(3, 0)
2168
2170
2171/* TODO(Botan4) this should use char for the out param */
2172BOTAN_FFI_EXPORT(2, 0)
2174 botan_x509_cert_t cert, const char* key, size_t index, uint8_t out[], size_t* out_len);
2175
2176/* TODO(Botan4) this should use char for the out param */
2177BOTAN_FFI_EXPORT(2, 0)
2179 botan_x509_cert_t cert, const char* key, size_t index, uint8_t out[], size_t* out_len);
2180
2181BOTAN_FFI_EXPORT(2, 0) int botan_x509_cert_to_string(botan_x509_cert_t cert, char out[], size_t* out_len);
2182
2183BOTAN_FFI_EXPORT(3, 0)
2185
2186/* Must match values of Key_Constraints in key_constraints.h */
2199
2200BOTAN_FFI_EXPORT(2, 0) int botan_x509_cert_allowed_usage(botan_x509_cert_t cert, unsigned int key_usage);
2201
2202/**
2203* Check if the certificate matches the specified hostname via alternative name or CN match.
2204* RFC 5280 wildcards also supported.
2205*/
2206BOTAN_FFI_EXPORT(2, 5) int botan_x509_cert_hostname_match(botan_x509_cert_t cert, const char* hostname);
2207
2208/**
2209* Returns 0 if the validation was successful, 1 if validation failed,
2210* and negative on error. A status code with details is written to
2211* *validation_result
2212*
2213* Intermediates or trusted lists can be null
2214* Trusted path can be null
2215*/
2216BOTAN_FFI_EXPORT(2, 8)
2217int botan_x509_cert_verify(int* validation_result,
2218 botan_x509_cert_t cert,
2219 const botan_x509_cert_t* intermediates,
2220 size_t intermediates_len,
2221 const botan_x509_cert_t* trusted,
2222 size_t trusted_len,
2223 const char* trusted_path,
2224 size_t required_strength,
2225 const char* hostname,
2226 uint64_t reference_time);
2227
2228/**
2229* Returns a pointer to a static character string explaining the status code,
2230* or else NULL if unknown.
2231*/
2232BOTAN_FFI_EXPORT(2, 8) const char* botan_x509_cert_validation_status(int code);
2233
2234/*
2235* X.509 CRL
2236**************************/
2237
2238typedef struct botan_x509_crl_struct* botan_x509_crl_t;
2239
2240BOTAN_FFI_EXPORT(2, 13) int botan_x509_crl_load_file(botan_x509_crl_t* crl_obj, const char* crl_path);
2241BOTAN_FFI_EXPORT(2, 13)
2242int botan_x509_crl_load(botan_x509_crl_t* crl_obj, const uint8_t crl_bits[], size_t crl_bits_len);
2243
2245
2246/**
2247 * Given a CRL and a certificate,
2248 * check if the certificate is revoked on that particular CRL
2249 */
2251
2252/**
2253 * Different flavor of `botan_x509_cert_verify`, supports revocation lists.
2254 * CRLs are passed as an array, same as intermediates and trusted CAs
2255 */
2256BOTAN_FFI_EXPORT(2, 13)
2257int botan_x509_cert_verify_with_crl(int* validation_result,
2258 botan_x509_cert_t cert,
2259 const botan_x509_cert_t* intermediates,
2260 size_t intermediates_len,
2261 const botan_x509_cert_t* trusted,
2262 size_t trusted_len,
2263 const botan_x509_crl_t* crls,
2264 size_t crls_len,
2265 const char* trusted_path,
2266 size_t required_strength,
2267 const char* hostname,
2268 uint64_t reference_time);
2269
2270/**
2271 * Key wrapping as per RFC 3394
2272 */
2273BOTAN_FFI_DEPRECATED("Use botan_nist_kw_enc")
2274BOTAN_FFI_EXPORT(2, 2)
2275int botan_key_wrap3394(const uint8_t key[],
2276 size_t key_len,
2277 const uint8_t kek[],
2278 size_t kek_len,
2279 uint8_t wrapped_key[],
2280 size_t* wrapped_key_len);
2281
2282BOTAN_FFI_DEPRECATED("Use botan_nist_kw_dec")
2283BOTAN_FFI_EXPORT(2, 2)
2284int botan_key_unwrap3394(const uint8_t wrapped_key[],
2285 size_t wrapped_key_len,
2286 const uint8_t kek[],
2287 size_t kek_len,
2288 uint8_t key[],
2289 size_t* key_len);
2290
2291BOTAN_FFI_EXPORT(3, 0)
2292int botan_nist_kw_enc(const char* cipher_algo,
2293 int padded,
2294 const uint8_t key[],
2295 size_t key_len,
2296 const uint8_t kek[],
2297 size_t kek_len,
2298 uint8_t wrapped_key[],
2299 size_t* wrapped_key_len);
2300
2301BOTAN_FFI_EXPORT(3, 0)
2302int botan_nist_kw_dec(const char* cipher_algo,
2303 int padded,
2304 const uint8_t wrapped_key[],
2305 size_t wrapped_key_len,
2306 const uint8_t kek[],
2307 size_t kek_len,
2308 uint8_t key[],
2309 size_t* key_len);
2310
2311/**
2312* HOTP
2313*/
2314
2315typedef struct botan_hotp_struct* botan_hotp_t;
2316
2317/**
2318* Initialize a HOTP instance
2319*/
2320BOTAN_FFI_EXPORT(2, 8)
2321int botan_hotp_init(botan_hotp_t* hotp, const uint8_t key[], size_t key_len, const char* hash_algo, size_t digits);
2322
2323/**
2324* Destroy a HOTP instance
2325* @return 0 if success, error if invalid object handle
2326*/
2327BOTAN_FFI_EXPORT(2, 8)
2329
2330/**
2331* Generate a HOTP code for the provided counter
2332*/
2333BOTAN_FFI_EXPORT(2, 8)
2334int botan_hotp_generate(botan_hotp_t hotp, uint32_t* hotp_code, uint64_t hotp_counter);
2335
2336/**
2337* Verify a HOTP code
2338*/
2339BOTAN_FFI_EXPORT(2, 8)
2341 botan_hotp_t hotp, uint64_t* next_hotp_counter, uint32_t hotp_code, uint64_t hotp_counter, size_t resync_range);
2342
2343/**
2344* TOTP
2345*/
2346
2347typedef struct botan_totp_struct* botan_totp_t;
2348
2349/**
2350* Initialize a TOTP instance
2351*/
2352BOTAN_FFI_EXPORT(2, 8)
2353int botan_totp_init(
2354 botan_totp_t* totp, const uint8_t key[], size_t key_len, const char* hash_algo, size_t digits, size_t time_step);
2355
2356/**
2357* Destroy a TOTP instance
2358* @return 0 if success, error if invalid object handle
2359*/
2360BOTAN_FFI_EXPORT(2, 8)
2362
2363/**
2364* Generate a TOTP code for the provided timestamp
2365* @param totp the TOTP object
2366* @param totp_code the OTP code will be written here
2367* @param timestamp the current local timestamp
2368*/
2369BOTAN_FFI_EXPORT(2, 8)
2370int botan_totp_generate(botan_totp_t totp, uint32_t* totp_code, uint64_t timestamp);
2371
2372/**
2373* Verify a TOTP code
2374* @param totp the TOTP object
2375* @param totp_code the presented OTP
2376* @param timestamp the current local timestamp
2377* @param acceptable_clock_drift specifies the acceptable amount
2378* of clock drift (in terms of time steps) between the two hosts.
2379*/
2380BOTAN_FFI_EXPORT(2, 8)
2381int botan_totp_check(botan_totp_t totp, uint32_t totp_code, uint64_t timestamp, size_t acceptable_clock_drift);
2382
2383/**
2384* Format Preserving Encryption
2385*/
2386
2387typedef struct botan_fpe_struct* botan_fpe_t;
2388
2389#define BOTAN_FPE_FLAG_FE1_COMPAT_MODE 1
2390
2391BOTAN_FFI_EXPORT(2, 8)
2393 botan_fpe_t* fpe, botan_mp_t n, const uint8_t key[], size_t key_len, size_t rounds, uint32_t flags);
2394
2395/**
2396* @return 0 if success, error if invalid object handle
2397*/
2398BOTAN_FFI_EXPORT(2, 8)
2400
2401BOTAN_FFI_EXPORT(2, 8)
2402int botan_fpe_encrypt(botan_fpe_t fpe, botan_mp_t x, const uint8_t tweak[], size_t tweak_len);
2403
2404BOTAN_FFI_EXPORT(2, 8)
2405int botan_fpe_decrypt(botan_fpe_t fpe, botan_mp_t x, const uint8_t tweak[], size_t tweak_len);
2406
2407/**
2408* SRP-6 Server Session type
2409*/
2410typedef struct botan_srp6_server_session_struct* botan_srp6_server_session_t;
2411
2412/**
2413* Initialize an SRP-6 server session object
2414* @param srp6 SRP-6 server session object
2415*/
2416BOTAN_FFI_EXPORT(3, 0)
2418
2419/**
2420* Frees all resources of the SRP-6 server session object
2421* @param srp6 SRP-6 server session object
2422* @return 0 if success, error if invalid object handle
2423*/
2424BOTAN_FFI_EXPORT(3, 0)
2426
2427/**
2428* SRP-6 Server side step 1
2429* @param srp6 SRP-6 server session object
2430* @param verifier the verification value saved from client registration
2431* @param verifier_len SRP-6 verifier value length
2432* @param group_id the SRP group id
2433* @param hash_id the SRP hash in use
2434* @param rng_obj a random number generator object
2435* @param B_pub out buffer to store the SRP-6 B value
2436* @param B_pub_len SRP-6 B value length
2437* @return 0 on success, negative on failure
2438*/
2439BOTAN_FFI_EXPORT(3, 0)
2441 const uint8_t verifier[],
2442 size_t verifier_len,
2443 const char* group_id,
2444 const char* hash_id,
2445 botan_rng_t rng_obj,
2446 uint8_t B_pub[],
2447 size_t* B_pub_len);
2448
2449/**
2450* SRP-6 Server side step 2
2451* @param srp6 SRP-6 server session object
2452* @param A the client's value
2453* @param A_len the client's value length
2454* @param key out buffer to store the symmetric key value
2455* @param key_len symmetric key length
2456* @return 0 on success, negative on failure
2457*/
2458BOTAN_FFI_EXPORT(3, 0)
2460 botan_srp6_server_session_t srp6, const uint8_t A[], size_t A_len, uint8_t key[], size_t* key_len);
2461
2462/**
2463* Generate a new SRP-6 verifier
2464* @param identifier a username or other client identifier
2465* @param password the secret used to authenticate user
2466* @param salt a randomly chosen value, at least 128 bits long
2467* @param salt_len the length of salt
2468* @param group_id specifies the shared SRP group
2469* @param hash_id specifies a secure hash function
2470* @param verifier out buffer to store the SRP-6 verifier value
2471* @param verifier_len SRP-6 verifier value length
2472* @return 0 on success, negative on failure
2473*/
2474BOTAN_FFI_EXPORT(3, 0)
2475int botan_srp6_generate_verifier(const char* identifier,
2476 const char* password,
2477 const uint8_t salt[],
2478 size_t salt_len,
2479 const char* group_id,
2480 const char* hash_id,
2481 uint8_t verifier[],
2482 size_t* verifier_len);
2483
2484/**
2485* SRP6a Client side
2486* @param username the username we are attempting login for
2487* @param password the password we are attempting to use
2488* @param group_id specifies the shared SRP group
2489* @param hash_id specifies a secure hash function
2490* @param salt is the salt value sent by the server
2491* @param salt_len the length of salt
2492* @param B is the server's public value
2493* @param B_len is the server's public value length
2494* @param rng_obj is a random number generator object
2495* @param A out buffer to store the SRP-6 A value
2496* @param A_len SRP-6 A verifier value length
2497* @param K out buffer to store the symmetric value
2498* @param K_len symmetric key length
2499* @return 0 on success, negative on failure
2500*/
2501BOTAN_FFI_EXPORT(3, 0)
2502int botan_srp6_client_agree(const char* username,
2503 const char* password,
2504 const char* group_id,
2505 const char* hash_id,
2506 const uint8_t salt[],
2507 size_t salt_len,
2508 const uint8_t B[],
2509 size_t B_len,
2510 botan_rng_t rng_obj,
2511 uint8_t A[],
2512 size_t* A_len,
2513 uint8_t K[],
2514 size_t* K_len);
2515
2516/**
2517* Return the size, in bytes, of the prime associated with group_id
2518*/
2519BOTAN_FFI_EXPORT(3, 0)
2520int botan_srp6_group_size(const char* group_id, size_t* group_p_bytes);
2521
2522/**
2523 * ZFEC
2524 */
2525
2526/**
2527 * Encode some bytes with certain ZFEC parameters.
2528 *
2529 * @param K the number of shares needed for recovery
2530 * @param N the number of shares generated
2531 * @param input the data to FEC
2532 * @param size the length in bytes of input, which must be a multiple of K
2533 *
2534 * @param outputs An out parameter pointing to a fully allocated array of size
2535 * [N][size / K]. For all n in range, an encoded block will be
2536 * written to the memory starting at outputs[n][0].
2537 *
2538 * @return 0 on success, negative on failure
2539 */
2540BOTAN_FFI_EXPORT(3, 0)
2541int botan_zfec_encode(size_t K, size_t N, const uint8_t* input, size_t size, uint8_t** outputs);
2542
2543/**
2544 * Decode some previously encoded shares using certain ZFEC parameters.
2545 *
2546 * @param K the number of shares needed for recovery
2547 * @param N the total number of shares
2548 *
2549 * @param indexes The index into the encoder's outputs for the corresponding
2550 * element of the inputs array. Must be of length K.
2551 *
2552 * @param inputs K previously encoded shares to decode
2553 * @param shareSize the length in bytes of each input
2554 *
2555 * @param outputs An out parameter pointing to a fully allocated array of size
2556 * [K][shareSize]. For all k in range, a decoded block will
2557 * written to the memory starting at outputs[k][0].
2558 *
2559 * @return 0 on success, negative on failure
2560 */
2561BOTAN_FFI_EXPORT(3, 0)
2563 size_t K, size_t N, const size_t* indexes, uint8_t* const* inputs, size_t shareSize, uint8_t** outputs);
2564
2565/**
2566* TPM2 context
2567*/
2568typedef struct botan_tpm2_ctx_struct* botan_tpm2_ctx_t;
2569
2570/**
2571* TPM2 session
2572*/
2573typedef struct botan_tpm2_session_struct* botan_tpm2_session_t;
2574
2575/**
2576* TPM2 crypto backend state object
2577*/
2578typedef struct botan_tpm2_crypto_backend_state_struct* botan_tpm2_crypto_backend_state_t;
2579
2580struct ESYS_CONTEXT;
2581
2582/**
2583* Checks if Botan's TSS2 crypto backend can be used in this build
2584* @returns 1 if the crypto backend can be enabled
2585*/
2586BOTAN_FFI_EXPORT(3, 6)
2588
2589/**
2590* Initialize a TPM2 context
2591* @param ctx_out output TPM2 context
2592* @param tcti_nameconf TCTI config (may be nullptr)
2593* @return 0 on success
2594*/
2595BOTAN_FFI_EXPORT(3, 6) int botan_tpm2_ctx_init(botan_tpm2_ctx_t* ctx_out, const char* tcti_nameconf);
2596
2597/**
2598* Initialize a TPM2 context
2599* @param ctx_out output TPM2 context
2600* @param tcti_name TCTI name (may be nullptr)
2601* @param tcti_conf TCTI config (may be nullptr)
2602* @return 0 on success
2603*/
2604BOTAN_FFI_EXPORT(3, 6)
2605int botan_tpm2_ctx_init_ex(botan_tpm2_ctx_t* ctx_out, const char* tcti_name, const char* tcti_conf);
2606
2607/**
2608* Wrap an existing ESYS_CONTEXT for use in Botan.
2609* Note that destroying the created botan_tpm2_ctx_t won't
2610* finalize @p esys_ctx
2611* @param ctx_out output TPM2 context
2612* @param esys_ctx ESYS_CONTEXT to wrap
2613* @return 0 on success
2614*/
2615BOTAN_FFI_EXPORT(3, 7)
2616int botan_tpm2_ctx_from_esys(botan_tpm2_ctx_t* ctx_out, struct ESYS_CONTEXT* esys_ctx);
2617
2618/**
2619* Enable Botan's TSS2 crypto backend that replaces the cryptographic functions
2620* required for the communication with the TPM with implementations provided
2621* by Botan instead of using TSS' defaults OpenSSL or mbedTLS.
2622* Note that the provided @p rng should not be dependent on the TPM and the
2623* caller must ensure that it remains usable for the lifetime of the @p ctx.
2624* @param ctx TPM2 context
2625* @param rng random number generator to be used by the crypto backend
2626*/
2627BOTAN_FFI_EXPORT(3, 6)
2629
2630/**
2631* Frees all resources of a TPM2 context
2632* @param ctx TPM2 context
2633* @return 0 on success
2634*/
2636
2637/**
2638* Use this if you just need Botan's crypto backend but do not want to wrap any
2639* other ESYS functionality using Botan's TPM2 wrapper.
2640* A Crypto Backend State is created that the user needs to keep alive for as
2641* long as the crypto backend is used and needs to be destroyed after.
2642* Note that the provided @p rng should not be dependent on the TPM and the
2643* caller must ensure that it remains usable for the lifetime of the @p esys_ctx.
2644* @param cbs_out To be created Crypto Backend State
2645* @param esys_ctx TPM2 context
2646* @param rng random number generator to be used by the crypto backend
2647*/
2648BOTAN_FFI_EXPORT(3, 7)
2650 struct ESYS_CONTEXT* esys_ctx,
2651 botan_rng_t rng);
2652
2653/**
2654* Frees all resources of a TPM2 Crypto Callback State
2655* Note that this does not attempt to de-register the crypto backend,
2656* it just frees the resource pointed to by @p cbs. Use the ESAPI function
2657* ``Esys_SetCryptoCallbacks(ctx, nullptr)`` to deregister manually.
2658* @param cbs TPM2 Crypto Callback State
2659* @return 0 on success
2660*/
2662
2663/**
2664* Initialize a random number generator object via TPM2
2665* @param rng_out rng object to create
2666* @param ctx TPM2 context
2667* @param s1 the first session to use (optional, may be nullptr)
2668* @param s2 the second session to use (optional, may be nullptr)
2669* @param s3 the third session to use (optional, may be nullptr)
2670*/
2671BOTAN_FFI_EXPORT(3, 6)
2672int botan_tpm2_rng_init(botan_rng_t* rng_out,
2673 botan_tpm2_ctx_t ctx,
2677
2678/**
2679* Create an unauthenticated session for use with TPM2
2680* @param session_out the session object to create
2681* @param ctx TPM2 context
2682*/
2683BOTAN_FFI_EXPORT(3, 6)
2685
2686/**
2687* Create an unauthenticated session for use with TPM2
2688* @param session the session object to destroy
2689*/
2690BOTAN_FFI_EXPORT(3, 6)
2692
2693/* NOLINTEND(*-macro-usage,*-misplaced-const) */
2694
2695#ifdef __cplusplus
2696}
2697#endif
2698
2699#endif
uint32_t botan_version_datestamp()
Definition ffi.cpp:302
int botan_same_mem(const uint8_t *x, const uint8_t *y, size_t len)
Definition ffi.cpp:312
const char * botan_version_string()
Definition ffi.cpp:286
int botan_base64_decode(const char *base64_str, size_t in_len, uint8_t *out, size_t *out_len)
Definition ffi.cpp:343
uint32_t botan_version_patch()
Definition ffi.cpp:298
int botan_base64_encode(const uint8_t *in, size_t len, char *out, size_t *out_len)
Definition ffi.cpp:336
int botan_scrub_mem(void *mem, size_t bytes)
Definition ffi.cpp:316
int botan_hex_encode(const uint8_t *in, size_t len, char *out, uint32_t flags)
Definition ffi.cpp:321
uint32_t botan_version_major()
Definition ffi.cpp:290
uint32_t botan_ffi_api_version()
Definition ffi.cpp:217
int botan_ffi_supports_api(uint32_t api_version)
Definition ffi.cpp:221
const char * botan_error_description(int err)
Definition ffi.cpp:143
uint32_t botan_version_minor()
Definition ffi.cpp:294
int botan_constant_time_compare(const uint8_t *x, const uint8_t *y, size_t len)
Definition ffi.cpp:306
int botan_hex_decode(const char *hex_str, size_t in_len, uint8_t *out, size_t *out_len)
Definition ffi.cpp:329
const char * botan_error_last_exception_message()
Definition ffi.cpp:139
int botan_mp_lshift(botan_mp_t out, botan_mp_t in, size_t shift)
Definition ffi_mp.cpp:236
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_is_revoked(botan_x509_crl_t crl, botan_x509_cert_t cert)
Definition ffi_cert.cpp:407
int botan_mp_is_prime(botan_mp_t n, botan_rng_t rng, size_t test_prob)
Definition ffi_mp.cpp:270
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)
Definition ffi_cert.cpp:398
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:170
int botan_mp_div(botan_mp_t quotient, botan_mp_t remainder, botan_mp_t x, botan_mp_t y)
Definition ffi_mp.cpp:198
int botan_mp_set_from_int(botan_mp_t mp, int initial_value)
Definition ffi_mp.cpp:38
int botan_mp_to_bin(botan_mp_t mp, uint8_t vec[])
Definition ffi_mp.cpp:126
int botan_x509_cert_destroy(botan_x509_cert_t cert)
Definition ffi_cert.cpp:164
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:2073
int botan_privkey_check_key(botan_privkey_t key, botan_rng_t rng, uint32_t flags)
Definition ffi_pkey.cpp:159
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:261
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:240
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:1558
int botan_mp_set_from_radix_str(botan_mp_t dest, const char *str, size_t radix)
Definition ffi_mp.cpp:46
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:148
int botan_oid_cmp(int *result, botan_asn1_oid_t a, botan_asn1_oid_t b)
Definition ffi_oid.cpp:64
int botan_mp_powmod(botan_mp_t out, botan_mp_t base, botan_mp_t exponent, botan_mp_t modulus)
Definition ffi_mp.cpp:231
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:128
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:134
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:98
int botan_mp_to_uint32(botan_mp_t mp, uint32_t *val)
Definition ffi_mp.cpp:137
int botan_pubkey_estimated_strength(botan_pubkey_t key, size_t *estimate)
Definition ffi_pkey.cpp:433
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:444
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_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:175
int botan_pk_op_key_agreement_export_public(botan_privkey_t key, uint8_t out[], size_t *out_len)
int botan_privkey_get_field(botan_mp_t output, botan_privkey_t key, const char *field_name)
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:119
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:52
#define BOTAN_FFI_EXPORT(maj, min)
Definition ffi.h:90
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:2410
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:23
int botan_tpm2_ctx_enable_crypto_backend(botan_tpm2_ctx_t ctx, botan_rng_t rng)
Definition ffi_tpm2.cpp:149
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:281
int botan_tpm2_ctx_init_ex(botan_tpm2_ctx_t *ctx_out, const char *tcti_name, const char *tcti_conf)
Definition ffi_tpm2.cpp:99
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_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:86
int botan_totp_generate(botan_totp_t totp, uint32_t *totp_code, uint64_t timestamp)
Definition ffi_totp.cpp:53
struct botan_pk_op_decrypt_struct * botan_pk_op_decrypt_t
Definition ffi.h:1952
struct botan_mac_struct * botan_mac_t
Definition ffi.h:461
int botan_mp_to_str(botan_mp_t mp, uint8_t radix, char *out, size_t *out_len)
Definition ffi_mp.cpp:102
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:31
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:214
struct botan_asn1_oid_struct * botan_asn1_oid_t
Definition ffi.h:1142
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:25
int botan_x509_cert_get_public_key(botan_x509_cert_t cert, botan_pubkey_t *key)
Definition ffi_cert.cpp:82
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:1325
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:23
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:327
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:437
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:193
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:30
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)
Definition ffi_cert.cpp:345
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_privkey_ed25519_get_privkey(botan_privkey_t key, uint8_t output[64])
struct botan_x509_crl_struct * botan_x509_crl_t
Definition ffi.h:2238
int botan_srp6_server_session_init(botan_srp6_server_session_t *srp6)
Definition ffi_srp6.cpp:31
struct botan_tpm2_session_struct * botan_tpm2_session_t
Definition ffi.h:2573
int botan_privkey_export_pubkey(botan_pubkey_t *out, botan_privkey_t in)
Definition ffi_pkey.cpp:135
int botan_tpm2_ctx_init(botan_tpm2_ctx_t *ctx_out, const char *tcti_nameconf)
Definition ffi_tpm2.cpp:74
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)
Definition ffi_cert.cpp:417
#define BOTAN_FFI_DEPRECATED(msg)
Definition ffi.h:105
int botan_mp_num_bytes(botan_mp_t n, size_t *bytes)
Definition ffi_mp.cpp:290
int botan_x509_cert_get_authority_key_id(botan_x509_cert_t cert, uint8_t out[], size_t *out_len)
Definition ffi_cert.cpp:233
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:100
int botan_pubkey_oid(botan_asn1_oid_t *oid, botan_pubkey_t key)
Definition ffi_pkey.cpp:377
int botan_pk_op_decrypt_destroy(botan_pk_op_decrypt_t op)
Definition ffi_pk_op.cpp:90
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:95
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:111
int botan_pubkey_algo_name(botan_pubkey_t key, char out[], size_t *out_len)
Definition ffi_pkey.cpp:147
struct botan_pk_op_encrypt_struct * botan_pk_op_encrypt_t
Definition ffi.h:1928
int botan_pubkey_view_pem(botan_pubkey_t key, botan_view_ctx ctx, botan_view_str_fn view)
Definition ffi_pkey.cpp:183
int botan_mp_from_bin(botan_mp_t mp, const uint8_t vec[], size_t vec_len)
Definition ffi_mp.cpp:80
int botan_ec_group_get_a(botan_mp_t *a, botan_ec_group_t ec_group)
Definition ffi_ec.cpp:162
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_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:168
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:84
int botan_privkey_view_der(botan_privkey_t key, botan_view_ctx ctx, botan_view_bin_fn view)
Definition ffi_pkey.cpp:205
int botan_privkey_stateful_operation(botan_privkey_t key, int *out)
Definition ffi_pkey.cpp:403
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:149
int botan_mp_swap(botan_mp_t x, botan_mp_t y)
Definition ffi_mp.cpp:226
struct botan_totp_struct * botan_totp_t
Definition ffi.h:2347
int botan_fpe_decrypt(botan_fpe_t fpe, botan_mp_t x, const uint8_t tweak[], size_t tweak_len)
Definition ffi_fpe.cpp:77
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:144
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:250
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_privkey_view_raw(botan_privkey_t key, botan_view_ctx ctx, botan_view_bin_fn view)
Definition ffi_pkey.cpp:215
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
int botan_ec_group_equal(botan_ec_group_t curve1, botan_ec_group_t curve2)
Definition ffi_ec.cpp:185
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:257
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_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:183
int botan_mp_equal(botan_mp_t x, botan_mp_t y)
Definition ffi_mp.cpp:206
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:307
int botan_srp6_server_session_destroy(botan_srp6_server_session_t srp6)
Definition ffi_srp6.cpp:41
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:123
int botan_totp_destroy(botan_totp_t totp)
Definition ffi_totp.cpp:44
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:41
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:42
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:255
int botan_mp_flip_sign(botan_mp_t mp)
Definition ffi_mp.cpp:76
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:178
int botan_privkey_remaining_operations(botan_privkey_t key, uint64_t *out)
Definition ffi_pkey.cpp:418
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:282
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)
struct botan_pk_op_kem_encrypt_struct * botan_pk_op_kem_encrypt_t
Definition ffi.h:2043
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:140
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:210
int botan_mp_mod_inverse(botan_mp_t out, botan_mp_t in, botan_mp_t modulus)
Definition ffi_mp.cpp:244
int botan_mp_cmp(int *result, botan_mp_t x, botan_mp_t y)
Definition ffi_mp.cpp:222
int botan_x509_cert_get_time_starts(botan_x509_cert_t cert, char out[], size_t *out_len)
Definition ffi_cert.cpp:173
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:166
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:2315
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:266
struct botan_block_cipher_struct * botan_block_cipher_t
Definition ffi.h:855
struct botan_ec_group_struct * botan_ec_group_t
Definition ffi.h:1191
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:55
int botan_privkey_oid(botan_asn1_oid_t *oid, botan_privkey_t key)
Definition ffi_pkey.cpp:390
int botan_x509_crl_load(botan_x509_crl_t *crl_obj, const uint8_t crl_bits[], size_t crl_bits_len)
Definition ffi_cert.cpp:381
int botan_mp_clear(botan_mp_t mp)
Definition ffi_mp.cpp:34
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_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:118
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:114
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:352
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:274
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:131
int botan_ec_group_get_order(botan_mp_t *order, botan_ec_group_t ec_group)
Definition ffi_ec.cpp:180
int botan_x509_cert_dup(botan_x509_cert_t *new_cert, botan_x509_cert_t cert)
Definition ffi_cert.cpp:47
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:278
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:220
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:161
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:193
int botan_hotp_destroy(botan_hotp_t hotp)
Definition ffi_hotp.cpp:43
int botan_mp_sub_u32(botan_mp_t result, botan_mp_t x, uint32_t y)
Definition ffi_mp.cpp:178
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:130
int botan_srp6_group_size(const char *group_id, size_t *group_p_bytes)
Definition ffi_srp6.cpp:45
int botan_ec_group_from_oid(botan_ec_group_t *ec_group, botan_asn1_oid_t oid)
Definition ffi_ec.cpp:97
struct botan_x509_cert_struct * botan_x509_cert_t
Definition ffi.h:2137
int botan_mp_num_bits(botan_mp_t n, size_t *bits)
Definition ffi_mp.cpp:286
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:51
struct botan_tpm2_ctx_struct * botan_tpm2_ctx_t
Definition ffi.h:2568
int botan_privkey_create(botan_privkey_t *key, const char *algo_name, const char *algo_params, botan_rng_t rng)
Definition ffi_pkey.cpp:29
int botan_x509_cert_hostname_match(botan_x509_cert_t cert, const char *hostname)
Definition ffi_cert.cpp:265
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:66
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:65
int botan_mp_mul(botan_mp_t result, botan_mp_t x, botan_mp_t y)
Definition ffi_mp.cpp:188
struct botan_pk_op_ka_struct * botan_pk_op_ka_t
Definition ffi.h:2014
int botan_privkey_algo_name(botan_privkey_t key, char out[], size_t *out_len)
Definition ffi_pkey.cpp:143
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:115
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:17
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:1975
int botan_tpm2_ctx_from_esys(botan_tpm2_ctx_t *ctx_out, struct ESYS_CONTEXT *esys_ctx)
Definition ffi_tpm2.cpp:132
int botan_x509_cert_get_serial_number(botan_x509_cert_t cert, uint8_t out[], size_t *out_len)
Definition ffi_cert.cpp:211
int botan_x509_cert_get_subject_key_id(botan_x509_cert_t cert, uint8_t out[], size_t *out_len)
Definition ffi_cert.cpp:242
int botan_pubkey_view_raw(botan_pubkey_t key, botan_view_ctx ctx, botan_view_bin_fn view)
Definition ffi_pkey.cpp:188
botan_x509_cert_key_constraints
Definition ffi.h:2187
@ KEY_ENCIPHERMENT
Definition ffi.h:2191
@ NO_CONSTRAINTS
Definition ffi.h:2188
@ CRL_SIGN
Definition ffi.h:2195
@ DIGITAL_SIGNATURE
Definition ffi.h:2189
@ KEY_AGREEMENT
Definition ffi.h:2193
@ DATA_ENCIPHERMENT
Definition ffi.h:2192
@ KEY_CERT_SIGN
Definition ffi.h:2194
@ ENCIPHER_ONLY
Definition ffi.h:2196
@ NON_REPUDIATION
Definition ffi.h:2190
@ DECIPHER_ONLY
Definition ffi.h:2197
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_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:60
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:921
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)
void * botan_view_ctx
Definition ffi.h:152
struct botan_rng_struct * botan_rng_t
Definition ffi.h:289
int botan_ec_group_get_b(botan_mp_t *b, botan_ec_group_t ec_group)
Definition ffi_ec.cpp:166
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:66
BOTAN_FFI_ERROR
Definition ffi.h:114
@ BOTAN_FFI_ERROR_TPM_ERROR
Definition ffi.h:144
@ BOTAN_FFI_ERROR_NOT_IMPLEMENTED
Definition ffi.h:138
@ BOTAN_FFI_ERROR_INVALID_KEY_LENGTH
Definition ffi.h:135
@ BOTAN_FFI_ERROR_KEY_NOT_SET
Definition ffi.h:134
@ BOTAN_FFI_ERROR_TLS_ERROR
Definition ffi.h:141
@ BOTAN_FFI_ERROR_EXCEPTION_THROWN
Definition ffi.h:126
@ BOTAN_FFI_ERROR_OUT_OF_MEMORY
Definition ffi.h:127
@ BOTAN_FFI_ERROR_INTERNAL_ERROR
Definition ffi.h:129
@ BOTAN_FFI_INVALID_VERIFIER
Definition ffi.h:117
@ BOTAN_FFI_ERROR_INVALID_OBJECT
Definition ffi.h:139
@ BOTAN_FFI_ERROR_UNKNOWN_ERROR
Definition ffi.h:146
@ BOTAN_FFI_ERROR_HTTP_ERROR
Definition ffi.h:142
@ BOTAN_FFI_ERROR_BAD_FLAG
Definition ffi.h:131
@ BOTAN_FFI_ERROR_INVALID_INPUT
Definition ffi.h:119
@ BOTAN_FFI_ERROR_STRING_CONVERSION_ERROR
Definition ffi.h:124
@ BOTAN_FFI_ERROR_NULL_POINTER
Definition ffi.h:132
@ BOTAN_FFI_SUCCESS
Definition ffi.h:115
@ BOTAN_FFI_ERROR_SYSTEM_ERROR
Definition ffi.h:128
@ BOTAN_FFI_ERROR_ROUGHTIME_ERROR
Definition ffi.h:143
@ BOTAN_FFI_ERROR_NO_VALUE
Definition ffi.h:121
@ BOTAN_FFI_ERROR_INVALID_OBJECT_STATE
Definition ffi.h:136
@ BOTAN_FFI_ERROR_INSUFFICIENT_BUFFER_SPACE
Definition ffi.h:123
@ BOTAN_FFI_ERROR_BAD_MAC
Definition ffi.h:120
@ BOTAN_FFI_ERROR_BAD_PARAMETER
Definition ffi.h:133
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:2578
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:55
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:25
int botan_cipher_clear(botan_cipher_t hash)
struct botan_pk_op_verify_struct * botan_pk_op_verify_t
Definition ffi.h:1995
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:255
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:218
int botan_ec_group_get_p(botan_mp_t *p, botan_ec_group_t ec_group)
Definition ffi_ec.cpp:158
int botan_tpm2_ctx_destroy(botan_tpm2_ctx_t ctx)
Definition ffi_tpm2.cpp:172
int botan_pubkey_check_key(botan_pubkey_t key, botan_rng_t rng, uint32_t flags)
Definition ffi_pkey.cpp:151
int botan_fpe_encrypt(botan_fpe_t fpe, botan_mp_t x, const uint8_t tweak[], size_t tweak_len)
Definition ffi_fpe.cpp:64
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)
Definition ffi_cert.cpp:364
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:60
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:557
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:149
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:27
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:170
int botan_x509_cert_not_after(botan_x509_cert_t cert, uint64_t *time_since_epoch)
Definition ffi_cert.cpp:202
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_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:68
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_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:251
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:158
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_x509_cert_get_fingerprint(botan_x509_cert_t cert, const char *hash, uint8_t out[], size_t *out_len)
Definition ffi_cert.cpp:220
int botan_rng_init(botan_rng_t *rng, const char *rng_type)
Definition ffi_rng.cpp:33
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:67
int botan_x509_cert_to_string(botan_x509_cert_t cert, char out[], size_t *out_len)
Definition ffi_cert.cpp:136
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:72
int botan_privkey_load_ed25519(botan_privkey_t *key, const uint8_t privkey[32])
struct botan_fpe_struct * botan_fpe_t
Definition ffi.h:2387
int botan_privkey_view_pem(botan_privkey_t key, botan_view_ctx ctx, botan_view_str_fn view)
Definition ffi_pkey.cpp:210
int botan_oid_destroy(botan_asn1_oid_t oid)
Definition ffi_oid.cpp:19
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:230
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_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_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:278
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:64
struct botan_hash_struct * botan_hash_t
Definition ffi.h:381
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)