Botan 3.9.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 specifed 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 20250506
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 botan_mp_num_bytes(mp)*2 + 1 bytes
936*/
937BOTAN_FFI_EXPORT(2, 1) int botan_mp_to_hex(botan_mp_t mp, char* out);
938
939/**
940* Convert the MPI to a string. Currently base == 10 and base == 16 are supported.
941*/
942BOTAN_FFI_EXPORT(2, 1) int botan_mp_to_str(botan_mp_t mp, uint8_t base, char* out, size_t* out_len);
943
944/**
945* Set the MPI to zero
946*/
948
949/**
950* Set the MPI value from an int
951*/
952BOTAN_FFI_EXPORT(2, 1) int botan_mp_set_from_int(botan_mp_t mp, int initial_value);
953
954/**
955* Set the MPI value from another MP object
956*/
958
959/**
960* Set the MPI value from a string
961*/
962BOTAN_FFI_EXPORT(2, 1) int botan_mp_set_from_str(botan_mp_t dest, const char* str);
963
964/**
965* Set the MPI value from a string with arbitrary radix.
966* For arbitrary being 10 or 16.
967*/
968BOTAN_FFI_EXPORT(2, 1) int botan_mp_set_from_radix_str(botan_mp_t dest, const char* str, size_t radix);
969
970/**
971* Return the number of significant bits in the MPI
972*/
973BOTAN_FFI_EXPORT(2, 1) int botan_mp_num_bits(botan_mp_t n, size_t* bits);
974
975/**
976* Return the number of significant bytes in the MPI
977*/
978BOTAN_FFI_EXPORT(2, 1) int botan_mp_num_bytes(botan_mp_t n, size_t* bytes);
979
980/*
981* Convert the MPI to a big-endian binary string. Writes botan_mp_num_bytes to vec
982*/
983BOTAN_FFI_EXPORT(2, 1) int botan_mp_to_bin(botan_mp_t mp, uint8_t vec[]);
984
985/*
986* Set an MP to the big-endian binary value
987*/
988BOTAN_FFI_EXPORT(2, 1) int botan_mp_from_bin(botan_mp_t mp, const uint8_t vec[], size_t vec_len);
989
990/*
991* Convert the MPI to a uint32_t, if possible. Fails if MPI is negative or too large.
992*/
993BOTAN_FFI_EXPORT(2, 1) int botan_mp_to_uint32(botan_mp_t mp, uint32_t* val);
994
995/**
996* This function should have been named mp_is_non_negative. Returns 1
997* iff mp is greater than *or equal to* zero. Use botan_mp_is_negative
998* to detect negative numbers, botan_mp_is_zero to check for zero.
999*/
1001
1002/**
1003* Return 1 iff mp is less than 0
1004*/
1006
1008
1010
1011BOTAN_FFI_DEPRECATED("Use botan_mp_get_bit(0)") BOTAN_FFI_EXPORT(2, 1) int botan_mp_is_odd(botan_mp_t mp);
1012BOTAN_FFI_DEPRECATED("Use botan_mp_get_bit(0)") BOTAN_FFI_EXPORT(2, 1) int botan_mp_is_even(botan_mp_t mp);
1013
1014BOTAN_FFI_EXPORT(2, 8) int botan_mp_add_u32(botan_mp_t result, botan_mp_t x, uint32_t y);
1015BOTAN_FFI_EXPORT(2, 8) int botan_mp_sub_u32(botan_mp_t result, botan_mp_t x, uint32_t y);
1016
1020
1021BOTAN_FFI_EXPORT(2, 1)
1022int botan_mp_div(botan_mp_t quotient, botan_mp_t remainder, botan_mp_t x, botan_mp_t y);
1023
1024BOTAN_FFI_EXPORT(2, 1)
1026
1027/*
1028* Returns 0 if x != y
1029* Returns 1 if x == y
1030* Returns negative number on error
1031*/
1033
1034/*
1035* Sets *result to comparison result:
1036* -1 if x < y, 0 if x == y, 1 if x > y
1037* Returns negative number on error or zero on success
1038*/
1039BOTAN_FFI_EXPORT(2, 1) int botan_mp_cmp(int* result, botan_mp_t x, botan_mp_t y);
1040
1041/*
1042* Swap two botan_mp_t
1043*/
1045
1046/* Return (base^exponent) % modulus */
1047BOTAN_FFI_EXPORT(2, 1)
1048int botan_mp_powmod(botan_mp_t out, botan_mp_t base, botan_mp_t exponent, botan_mp_t modulus);
1049
1050BOTAN_FFI_EXPORT(2, 1) int botan_mp_lshift(botan_mp_t out, botan_mp_t in, size_t shift);
1051BOTAN_FFI_EXPORT(2, 1) int botan_mp_rshift(botan_mp_t out, botan_mp_t in, size_t shift);
1052
1054
1055BOTAN_FFI_EXPORT(2, 1) int botan_mp_rand_bits(botan_mp_t rand_out, botan_rng_t rng, size_t bits);
1056
1057BOTAN_FFI_EXPORT(2, 1)
1058int botan_mp_rand_range(botan_mp_t rand_out, botan_rng_t rng, botan_mp_t lower_bound, botan_mp_t upper_bound);
1059
1061
1062/**
1063* Returns 0 if n is not prime
1064* Returns 1 if n is prime
1065* Returns negative number on error
1066*/
1067BOTAN_FFI_EXPORT(2, 1) int botan_mp_is_prime(botan_mp_t n, botan_rng_t rng, size_t test_prob);
1068
1069/**
1070* Returns 0 if specified bit of n is not set
1071* Returns 1 if specified bit of n is set
1072* Returns negative number on error
1073*/
1074BOTAN_FFI_EXPORT(2, 1) int botan_mp_get_bit(botan_mp_t n, size_t bit);
1075
1076/**
1077* Set the specified bit
1078*/
1079BOTAN_FFI_EXPORT(2, 1) int botan_mp_set_bit(botan_mp_t n, size_t bit);
1080
1081/**
1082* Clear the specified bit
1083*/
1084BOTAN_FFI_EXPORT(2, 1) int botan_mp_clear_bit(botan_mp_t n, size_t bit);
1085
1086/* Bcrypt password hashing */
1087
1088/**
1089* Create a password hash using Bcrypt
1090* @param out buffer holding the password hash, should be of length 64 bytes
1091* @param out_len the desired output length in bytes
1092* @param password the password
1093* @param rng a random number generator
1094* @param work_factor how much work to do to slow down guessing attacks
1095* @param flags should be 0 in current API revision, all other uses are reserved
1096* and return BOTAN_FFI_ERROR_BAD_FLAG
1097* @return 0 on success, a negative value on failure
1098*
1099* Output is formatted bcrypt $2a$...
1100*
1101* TOD(Botan4) this should use char for the type of `out`
1102*/
1103BOTAN_FFI_EXPORT(2, 0)
1105 uint8_t* out, size_t* out_len, const char* password, botan_rng_t rng, size_t work_factor, uint32_t flags);
1106
1107/**
1108* Check a previously created password hash
1109* @param pass the password to check against
1110* @param hash the stored hash to check against
1111* @return 0 if if this password/hash combination is valid,
1112* 1 if the combination is not valid (but otherwise well formed),
1113* negative on error
1114*/
1115BOTAN_FFI_EXPORT(2, 0) int botan_bcrypt_is_valid(const char* pass, const char* hash);
1116
1117/*
1118* OIDs
1119*/
1120
1121typedef struct botan_asn1_oid_struct* botan_asn1_oid_t;
1122
1123/**
1124* @returns negative number on error, or zero on success
1125*/
1127
1128/**
1129* Create an OID from a string, either dot notation (e.g. '1.2.3.4') or a registered name (e.g. 'RSA')
1130* @param oid hanlder to the resulting OID
1131* @param oid_str the name of the OID to create
1132* @returns negative number on error, or zero on success
1133*/
1134BOTAN_FFI_EXPORT(3, 8) int botan_oid_from_string(botan_asn1_oid_t* oid, const char* oid_str);
1135
1136/**
1137* Registers an OID so that it may later be retrieved by name
1138* @returns negative number on error, or zero on success
1139*/
1140BOTAN_FFI_EXPORT(3, 8) int botan_oid_register(botan_asn1_oid_t oid, const char* name);
1141
1142/**
1143* View an OID in dot notation
1144*/
1146
1147/**
1148* View an OIDs registered name if it exists, else its dot notation
1149*/
1151
1152/**
1153* @returns 0 if a != b
1154* @returns 1 if a == b
1155* @returns negative number on error
1156*/
1158
1159/**
1160* Sets @param result to comparison result:
1161* -1 if a < b, 0 if a == b, 1 if a > b
1162* @returns negative number on error or zero on success
1163*/
1165
1166/*
1167* EC Groups
1168*/
1169
1170typedef struct botan_ec_group_struct* botan_ec_group_t;
1171
1172/**
1173* @returns negative number on error, or zero on success
1174*/
1176
1177/**
1178* Checks if in this build configuration it is possible to register an application specific elliptic curve and sets
1179* @param out to 1 if so, 0 otherwise
1180* @returns 0 on success, a negative value on failure
1181*/
1183
1184/**
1185* Checks if in this build configuration botan_ec_group_from_name(group_ptr, name) will succeed and sets
1186* @param out to 1 if so, 0 otherwise.
1187* @returns negative number on error, or zero on success
1188*/
1189BOTAN_FFI_EXPORT(3, 8) int botan_ec_group_supports_named_group(const char* name, int* out);
1190
1191/**
1192* Create a new EC Group from parameters
1193* @warning use only elliptic curve parameters that you trust
1194*
1195* @param ec_group the new object will be placed here
1196* @param p the elliptic curve prime (at most 521 bits)
1197* @param a the elliptic curve a param
1198* @param b the elliptic curve b param
1199* @param base_x the x coordinate of the group generator
1200* @param base_y the y coordinate of the group generator
1201* @param order the order of the group
1202* @returns negative number on error, or zero on success
1203*/
1204BOTAN_FFI_EXPORT(3, 8)
1206 botan_asn1_oid_t oid,
1207 botan_mp_t p,
1208 botan_mp_t a,
1209 botan_mp_t b,
1210 botan_mp_t base_x,
1211 botan_mp_t base_y,
1212 botan_mp_t order);
1213
1214/**
1215* Decode a BER encoded ECC domain parameter set
1216* @param ec_group the new object will be placed here
1217* @param ber encoding
1218* @param ber_len size of the encoding in bytes
1219* @returns negative number on error, or zero on success
1220*/
1221BOTAN_FFI_EXPORT(3, 8) int botan_ec_group_from_ber(botan_ec_group_t* ec_group, const uint8_t* ber, size_t ber_len);
1222
1223/**
1224* Initialize an EC Group from the PEM/ASN.1 encoding
1225* @param ec_group the new object will be placed here
1226* @param pem encoding
1227* @returns negative number on error, or zero on success
1228*/
1229BOTAN_FFI_EXPORT(3, 8) int botan_ec_group_from_pem(botan_ec_group_t* ec_group, const char* pem);
1230
1231/**
1232* Initialize an EC Group from a group named by an object identifier
1233* @param ec_group the new object will be placed here
1234* @param oid a known OID
1235* @returns negative number on error, or zero on success
1236*/
1238
1239/**
1240* Initialize an EC Group from a common group name (eg "secp256r1")
1241* @param ec_group the new object will be placed here
1242* @param name a known group name
1243* @returns negative number on error, or zero on success
1244*/
1245BOTAN_FFI_EXPORT(3, 8) int botan_ec_group_from_name(botan_ec_group_t* ec_group, const char* name);
1246
1247/**
1248* View an EC Group in DER encoding
1249*/
1250BOTAN_FFI_EXPORT(3, 8)
1252
1253/**
1254* View an EC Group in PEM encoding
1255*/
1256BOTAN_FFI_EXPORT(3, 8)
1258
1259/**
1260* Get the curve OID of an EC Group
1261*/
1263
1264/**
1265* Get the prime modulus of the field
1266*/
1268
1269/**
1270* Get the a parameter of the elliptic curve equation
1271*/
1273
1274/**
1275* Get the b parameter of the elliptic curve equation
1276*/
1278
1279/**
1280* Get the x coordinate of the base point
1281*/
1283
1284/**
1285* Get the y coordinate of the base point
1286*/
1288
1289/**
1290* Get the order of the base point
1291*/
1293
1294/**
1295* @returns 0 if curve1 != curve2
1296* @returns 1 if curve1 == curve2
1297* @returns negative number on error
1298*/
1300
1301/*
1302* Public/private key creation, import, ...
1303*/
1304typedef struct botan_privkey_struct* botan_privkey_t;
1305
1306/**
1307* Create a new private key
1308* @param key the new object will be placed here
1309* @param algo_name something like "RSA" or "ECDSA"
1310* @param algo_params is specific to the algorithm. For RSA, specifies
1311* the modulus bit length. For ECC is the name of the curve.
1312* @param rng a random number generator
1313*/
1314BOTAN_FFI_EXPORT(2, 0)
1315int botan_privkey_create(botan_privkey_t* key, const char* algo_name, const char* algo_params, botan_rng_t rng);
1316
1317/**
1318* Create a new ec private key
1319* @param key the new object will be placed here
1320* @param algo_name something like "ECDSA" or "ECDH"
1321* @param ec_group a (possibly application specific) elliptic curve
1322* @param rng a random number generator
1323*/
1324BOTAN_FFI_EXPORT(3, 8)
1325int botan_ec_privkey_create(botan_privkey_t* key, const char* algo_name, botan_ec_group_t ec_group, botan_rng_t rng);
1326
1327#define BOTAN_CHECK_KEY_EXPENSIVE_TESTS 1
1328
1329BOTAN_FFI_EXPORT(2, 0) int botan_privkey_check_key(botan_privkey_t key, botan_rng_t rng, uint32_t flags);
1330
1331BOTAN_FFI_DEPRECATED("Use botan_privkey_create")
1332BOTAN_FFI_EXPORT(2, 0) int botan_privkey_create_rsa(botan_privkey_t* key, botan_rng_t rng, size_t n_bits);
1333BOTAN_FFI_DEPRECATED("Use botan_privkey_create")
1334BOTAN_FFI_EXPORT(2, 0) int botan_privkey_create_ecdsa(botan_privkey_t* key, botan_rng_t rng, const char* params);
1335BOTAN_FFI_DEPRECATED("Use botan_privkey_create")
1336BOTAN_FFI_EXPORT(2, 0) int botan_privkey_create_ecdh(botan_privkey_t* key, botan_rng_t rng, const char* params);
1337BOTAN_FFI_DEPRECATED("Use botan_privkey_create")
1338BOTAN_FFI_EXPORT(2, 0) int botan_privkey_create_mceliece(botan_privkey_t* key, botan_rng_t rng, size_t n, size_t t);
1339BOTAN_FFI_DEPRECATED("Use botan_privkey_create")
1340BOTAN_FFI_EXPORT(2, 0) int botan_privkey_create_dh(botan_privkey_t* key, botan_rng_t rng, const char* param);
1341
1342/**
1343 * Generates DSA key pair. Gives to a caller control over key length
1344 * and order of a subgroup 'q'.
1345 *
1346 * @param key handler to the resulting key
1347 * @param rng initialized PRNG
1348 * @param pbits length of the key in bits. Must be between in range (1024, 3072)
1349 * and multiple of 64. Bit size of the prime 'p'
1350 * @param qbits order of the subgroup. Must be in range (160, 256) and multiple
1351 * of 8
1352 *
1353 * @returns BOTAN_FFI_SUCCESS Success, `key' initialized with DSA key
1354 * @returns BOTAN_FFI_ERROR_NULL_POINTER either `key' or `rng' is NULL
1355 * @returns BOTAN_FFI_ERROR_BAD_PARAMETER unexpected value for either `pbits' or
1356 * `qbits'
1357 * @returns BOTAN_FFI_ERROR_NOT_IMPLEMENTED functionality not implemented
1358 *
1359*/
1360BOTAN_FFI_EXPORT(2, 5) int botan_privkey_create_dsa(botan_privkey_t* key, botan_rng_t rng, size_t pbits, size_t qbits);
1361
1362/**
1363 * Generates ElGamal key pair. Caller has a control over key length
1364 * and order of a subgroup 'q'. Function is able to use two types of
1365 * primes:
1366 * * if pbits-1 == qbits then safe primes are used for key generation
1367 * * otherwise generation uses group of prime order
1368 *
1369 * @param key handler to the resulting key
1370 * @param rng initialized PRNG
1371 * @param pbits length of the key in bits. Must be at least 1024
1372 * @param qbits order of the subgroup. Must be at least 160
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)
1382int botan_privkey_create_elgamal(botan_privkey_t* key, botan_rng_t rng, size_t pbits, size_t qbits);
1383
1384/**
1385* Input currently assumed to be PKCS #8 structure;
1386* Set password to NULL to indicate no encryption expected
1387* Starting in 2.8.0, the rng parameter is unused and may be set to null
1388*/
1389BOTAN_FFI_EXPORT(2, 0)
1390int botan_privkey_load(botan_privkey_t* key, botan_rng_t rng, const uint8_t bits[], size_t len, const char* password);
1391
1392/**
1393* @return 0 if success, error if invalid object handle
1394*/
1396
1397#define BOTAN_PRIVKEY_EXPORT_FLAG_DER 0
1398#define BOTAN_PRIVKEY_EXPORT_FLAG_PEM 1
1399#define BOTAN_PRIVKEY_EXPORT_FLAG_RAW 2
1400
1401/**
1402* On input *out_len is number of bytes in out[]
1403* On output *out_len is number of bytes written (or required)
1404* If out is not big enough no output is written, *out_len is set and 1 is returned
1405* Returns 0 on success and sets
1406* If some other error occurs a negative integer is returned.
1407*/
1408BOTAN_FFI_DEPRECATED("Use botan_privkey_view_{der,pem,raw}")
1409BOTAN_FFI_EXPORT(2, 0) int botan_privkey_export(botan_privkey_t key, uint8_t out[], size_t* out_len, uint32_t flags);
1410
1411/**
1412* View the private key's DER encoding
1413*/
1415
1416/**
1417* View the private key's PEM encoding
1418*/
1420
1421/**
1422* View the private key's raw encoding
1423*/
1425
1426BOTAN_FFI_EXPORT(2, 8) int botan_privkey_algo_name(botan_privkey_t key, char out[], size_t* out_len);
1427
1428/**
1429* Set encryption_algo to NULL or "" to have the library choose a default (recommended)
1430*/
1431BOTAN_FFI_DEPRECATED("Use botan_privkey_export_encrypted_pbkdf_{msec,iter}")
1432BOTAN_FFI_EXPORT(2, 0)
1434 uint8_t out[],
1435 size_t* out_len,
1436 botan_rng_t rng,
1437 const char* passphrase,
1438 const char* encryption_algo,
1439 uint32_t flags);
1440
1441/*
1442* Export a private key, running PBKDF for specified amount of time
1443* @param key the private key to export
1444*
1445* Note: starting in 3.0, the output iterations count is not provided
1446*/
1447BOTAN_FFI_DEPRECATED("Use botan_privkey_view_encrypted_{der,pem}_timed")
1448BOTAN_FFI_EXPORT(2, 0)
1450 uint8_t out[],
1451 size_t* out_len,
1452 botan_rng_t rng,
1453 const char* passphrase,
1454 uint32_t pbkdf_msec_runtime,
1455 size_t* pbkdf_iterations_out,
1456 const char* cipher_algo,
1457 const char* pbkdf_algo,
1458 uint32_t flags);
1459
1460/**
1461* Export a private key using the specified number of iterations.
1462*/
1463BOTAN_FFI_DEPRECATED("Use botan_privkey_view_encrypted_{der,pem}")
1464BOTAN_FFI_EXPORT(2, 0)
1466 uint8_t out[],
1467 size_t* out_len,
1468 botan_rng_t rng,
1469 const char* passphrase,
1470 size_t pbkdf_iterations,
1471 const char* cipher_algo,
1472 const char* pbkdf_algo,
1473 uint32_t flags);
1474
1475/**
1476* View the encryption of a private key (binary DER encoding)
1477*
1478* Set cipher_algo, pbkdf_algo to NULL to use defaults
1479* Set pbkdf_iterations to 0 to use defaults
1480*/
1481BOTAN_FFI_EXPORT(3, 0)
1483 botan_rng_t rng,
1484 const char* passphrase,
1485 const char* cipher_algo,
1486 const char* pbkdf_algo,
1487 size_t pbkdf_iterations,
1488 botan_view_ctx ctx,
1489 botan_view_bin_fn view);
1490
1491/**
1492* View the encryption of a private key (binary DER encoding)
1493*
1494* Set cipher_algo, pbkdf_algo to NULL to use defaults
1495*/
1496BOTAN_FFI_EXPORT(3, 0)
1498 botan_rng_t rng,
1499 const char* passphrase,
1500 const char* cipher_algo,
1501 const char* pbkdf_algo,
1502 size_t pbkdf_runtime_msec,
1503 botan_view_ctx ctx,
1504 botan_view_bin_fn view);
1505
1506/**
1507* View the encryption of a private key (PEM encoding)
1508*
1509* Set cipher_algo, pbkdf_algo to NULL to use defaults
1510* Set pbkdf_iterations to 0 to use defaults
1511*/
1512BOTAN_FFI_EXPORT(3, 0)
1514 botan_rng_t rng,
1515 const char* passphrase,
1516 const char* cipher_algo,
1517 const char* pbkdf_algo,
1518 size_t pbkdf_iterations,
1519 botan_view_ctx ctx,
1520 botan_view_str_fn view);
1521
1522/**
1523* View the encryption of a private key (PEM encoding)
1524*
1525* Set cipher_algo, pbkdf_algo to NULL to use defaults
1526*/
1527BOTAN_FFI_EXPORT(3, 0)
1529 botan_rng_t rng,
1530 const char* passphrase,
1531 const char* cipher_algo,
1532 const char* pbkdf_algo,
1533 size_t pbkdf_runtime_msec,
1534 botan_view_ctx ctx,
1535 botan_view_str_fn view);
1536
1537typedef struct botan_pubkey_struct* botan_pubkey_t;
1538
1539BOTAN_FFI_EXPORT(2, 0) int botan_pubkey_load(botan_pubkey_t* key, const uint8_t bits[], size_t len);
1540
1542
1543BOTAN_FFI_DEPRECATED("Use botan_pubkey_view_{der,pem,raw}")
1544BOTAN_FFI_EXPORT(2, 0) int botan_pubkey_export(botan_pubkey_t key, uint8_t out[], size_t* out_len, uint32_t flags);
1545
1546/**
1547* View the public key's DER encoding
1548*/
1550
1551/**
1552* View the public key's PEM encoding
1553*/
1555
1556/**
1557* View the public key's raw encoding
1558*/
1560
1561BOTAN_FFI_EXPORT(2, 0) int botan_pubkey_algo_name(botan_pubkey_t key, char out[], size_t* out_len);
1562
1563/**
1564* Returns 0 if key is valid, negative if invalid key or some other error
1565*/
1566BOTAN_FFI_EXPORT(2, 0) int botan_pubkey_check_key(botan_pubkey_t key, botan_rng_t rng, uint32_t flags);
1567
1568BOTAN_FFI_EXPORT(2, 0) int botan_pubkey_estimated_strength(botan_pubkey_t key, size_t* estimate);
1569
1570BOTAN_FFI_EXPORT(2, 0)
1571int botan_pubkey_fingerprint(botan_pubkey_t key, const char* hash, uint8_t out[], size_t* out_len);
1572
1573/**
1574* @return 0 if success, error if invalid object handle
1575*/
1577
1578/*
1579* Get arbitrary named fields from public or private keys
1580*/
1581BOTAN_FFI_EXPORT(2, 0) int botan_pubkey_get_field(botan_mp_t output, botan_pubkey_t key, const char* field_name);
1582
1583BOTAN_FFI_EXPORT(2, 0) int botan_privkey_get_field(botan_mp_t output, botan_privkey_t key, const char* field_name);
1584
1585/*
1586* Get the OID from public or private keys
1587*/
1588BOTAN_FFI_EXPORT(3, 8)
1590
1591BOTAN_FFI_EXPORT(3, 8)
1593
1594/**
1595* Checks whether a key is stateful and sets
1596* @param out to 1 if it is, or 0 if the key is not stateful
1597* @return 0 on success, a negative value on failure
1598*/
1600
1601/**
1602* Gets information on many operations a (stateful) key has remaining and sets
1603* @param out to that value
1604* @return 0 on success, a negative value on failure or if the key is not stateful
1605*/
1607
1608/*
1609* Algorithm specific key operations: RSA
1610*/
1612
1613BOTAN_FFI_EXPORT(2, 8) int botan_privkey_load_rsa_pkcs1(botan_privkey_t* key, const uint8_t bits[], size_t len);
1614
1615BOTAN_FFI_DEPRECATED("Use botan_privkey_get_field")
1617BOTAN_FFI_DEPRECATED("Use botan_privkey_get_field")
1619BOTAN_FFI_DEPRECATED("Use botan_privkey_get_field")
1621BOTAN_FFI_DEPRECATED("Use botan_privkey_get_field")
1623BOTAN_FFI_DEPRECATED("Use botan_privkey_get_field")
1625
1626BOTAN_FFI_EXPORT(2, 8)
1627int botan_privkey_rsa_get_privkey(botan_privkey_t rsa_key, uint8_t out[], size_t* out_len, uint32_t flags);
1628
1630
1631BOTAN_FFI_DEPRECATED("Use botan_pubkey_get_field")
1633BOTAN_FFI_DEPRECATED("Use botan_pubkey_get_field")
1635
1636/*
1637* Algorithm specific key operations: DSA
1638*/
1639BOTAN_FFI_EXPORT(2, 0)
1641
1642BOTAN_FFI_EXPORT(2, 0)
1644
1645BOTAN_FFI_DEPRECATED("Use botan_privkey_get_field")
1647
1648BOTAN_FFI_DEPRECATED("Use botan_pubkey_get_field")
1650BOTAN_FFI_DEPRECATED("Use botan_pubkey_get_field")
1652BOTAN_FFI_DEPRECATED("Use botan_pubkey_get_field")
1654BOTAN_FFI_DEPRECATED("Use botan_pubkey_get_field")
1656
1657/*
1658* Loads Diffie Hellman private key
1659*
1660* @param key variable populated with key material
1661* @param p prime order of a Z_p group
1662* @param g group generator
1663* @param x private key
1664*
1665* @pre key is NULL on input
1666* @post function allocates memory and assigns to `key'
1667*
1668* @return 0 on success, a negative value on failure
1669*/
1671/**
1672* Loads Diffie Hellman public key
1673*
1674* @param key variable populated with key material
1675* @param p prime order of a Z_p group
1676* @param g group generator
1677* @param y public key
1678*
1679* @pre key is NULL on input
1680* @post function allocates memory and assigns to `key'
1681*
1682* @return 0 on success, a negative value on failure
1683*/
1685
1686/*
1687* Algorithm specific key operations: ElGamal
1688*/
1689
1690/**
1691* Loads ElGamal public key
1692* @param key variable populated with key material
1693* @param p prime order of a Z_p group
1694* @param g group generator
1695* @param y public key
1696*
1697* @pre key is NULL on input
1698* @post function allocates memory and assigns to `key'
1699*
1700* @return 0 on success, a negative value on failure
1701*/
1703
1704/**
1705* Loads ElGamal private key
1706*
1707* @param key variable populated with key material
1708* @param p prime order of a Z_p group
1709* @param g group generator
1710* @param x private key
1711*
1712* @pre key is NULL on input
1713* @post function allocates memory and assigns to `key'
1714*
1715* @return 0 on success, a negative value on failure
1716*/
1718
1719/*
1720* Algorithm specific key operations: Ed25519
1721*/
1722
1723BOTAN_FFI_EXPORT(2, 2) int botan_privkey_load_ed25519(botan_privkey_t* key, const uint8_t privkey[32]);
1724
1725BOTAN_FFI_EXPORT(2, 2) int botan_pubkey_load_ed25519(botan_pubkey_t* key, const uint8_t pubkey[32]);
1726
1727BOTAN_FFI_DEPRECATED("Use botan_privkey_view_raw")
1728BOTAN_FFI_EXPORT(2, 2) int botan_privkey_ed25519_get_privkey(botan_privkey_t key, uint8_t output[64]);
1729
1730BOTAN_FFI_DEPRECATED("Use botan_pubkey_view_raw")
1731BOTAN_FFI_EXPORT(2, 2) int botan_pubkey_ed25519_get_pubkey(botan_pubkey_t key, uint8_t pubkey[32]);
1732
1733/*
1734* Algorithm specific key operations: Ed448
1735*/
1736
1737BOTAN_FFI_EXPORT(3, 4) int botan_privkey_load_ed448(botan_privkey_t* key, const uint8_t privkey[57]);
1738
1739BOTAN_FFI_EXPORT(3, 4) int botan_pubkey_load_ed448(botan_pubkey_t* key, const uint8_t pubkey[57]);
1740
1741BOTAN_FFI_DEPRECATED("Use botan_privkey_view_raw")
1742BOTAN_FFI_EXPORT(3, 4) int botan_privkey_ed448_get_privkey(botan_privkey_t key, uint8_t output[57]);
1743
1744BOTAN_FFI_DEPRECATED("Use botan_pubkey_view_raw")
1745BOTAN_FFI_EXPORT(3, 4) int botan_pubkey_ed448_get_pubkey(botan_pubkey_t key, uint8_t pubkey[57]);
1746
1747/*
1748* Algorithm specific key operations: X25519
1749*/
1750
1751BOTAN_FFI_EXPORT(2, 8) int botan_privkey_load_x25519(botan_privkey_t* key, const uint8_t privkey[32]);
1752
1753BOTAN_FFI_EXPORT(2, 8) int botan_pubkey_load_x25519(botan_pubkey_t* key, const uint8_t pubkey[32]);
1754
1755BOTAN_FFI_DEPRECATED("Use botan_privkey_view_raw")
1756BOTAN_FFI_EXPORT(2, 8) int botan_privkey_x25519_get_privkey(botan_privkey_t key, uint8_t output[32]);
1757
1758BOTAN_FFI_DEPRECATED("Use botan_pubkey_view_raw")
1759BOTAN_FFI_EXPORT(2, 8) int botan_pubkey_x25519_get_pubkey(botan_pubkey_t key, uint8_t pubkey[32]);
1760
1761/*
1762* Algorithm specific key operations: X448
1763*/
1764
1765BOTAN_FFI_EXPORT(3, 4) int botan_privkey_load_x448(botan_privkey_t* key, const uint8_t privkey[56]);
1766
1767BOTAN_FFI_EXPORT(3, 4) int botan_pubkey_load_x448(botan_pubkey_t* key, const uint8_t pubkey[56]);
1768
1769BOTAN_FFI_DEPRECATED("Use botan_privkey_view_raw")
1770BOTAN_FFI_EXPORT(3, 4) int botan_privkey_x448_get_privkey(botan_privkey_t key, uint8_t output[56]);
1771
1772BOTAN_FFI_DEPRECATED("Use botan_pubkey_view_raw")
1773BOTAN_FFI_EXPORT(3, 4) int botan_pubkey_x448_get_pubkey(botan_pubkey_t key, uint8_t pubkey[56]);
1774
1775/*
1776* Algorithm specific key operations: ML-DSA
1777*/
1778
1779BOTAN_FFI_EXPORT(3, 6)
1780int botan_privkey_load_ml_dsa(botan_privkey_t* key, const uint8_t privkey[], size_t key_len, const char* mldsa_mode);
1781
1782BOTAN_FFI_EXPORT(3, 6)
1783int botan_pubkey_load_ml_dsa(botan_pubkey_t* key, const uint8_t pubkey[], size_t key_len, const char* mldsa_mode);
1784
1785/*
1786* Algorithm specific key operations: Kyber R3
1787*
1788* Note that Kyber R3 support is somewhat deprecated and may be removed in a
1789* future major release. Using the final ML-KEM is highly recommended in any new
1790* system.
1791*/
1792
1793BOTAN_FFI_DEPRECATED("Kyber R3 support is deprecated")
1794BOTAN_FFI_EXPORT(3, 1) int botan_privkey_load_kyber(botan_privkey_t* key, const uint8_t privkey[], size_t key_len);
1795
1796BOTAN_FFI_DEPRECATED("Kyber R3 support is deprecated")
1797BOTAN_FFI_EXPORT(3, 1) int botan_pubkey_load_kyber(botan_pubkey_t* key, const uint8_t pubkey[], size_t key_len);
1798
1799BOTAN_FFI_DEPRECATED("Use generic botan_privkey_view_raw")
1800BOTAN_FFI_EXPORT(3, 1)
1802
1803BOTAN_FFI_DEPRECATED("Use generic botan_pubkey_view_raw")
1804BOTAN_FFI_EXPORT(3, 1)
1806
1807/**
1808* Algorithm specific key operation: FrodoKEM
1809*/
1810
1811BOTAN_FFI_EXPORT(3, 6)
1812int botan_privkey_load_frodokem(botan_privkey_t* key, const uint8_t privkey[], size_t key_len, const char* frodo_mode);
1813
1814BOTAN_FFI_EXPORT(3, 6)
1815int botan_pubkey_load_frodokem(botan_pubkey_t* key, const uint8_t pubkey[], size_t key_len, const char* frodo_mode);
1816
1817/**
1818* Algorithm specific key operation: Classic McEliece
1819*/
1820
1821BOTAN_FFI_EXPORT(3, 6)
1823 const uint8_t privkey[],
1824 size_t key_len,
1825 const char* cmce_mode);
1826
1827BOTAN_FFI_EXPORT(3, 6)
1829 const uint8_t pubkey[],
1830 size_t key_len,
1831 const char* cmce_mode);
1832
1833/*
1834* Algorithm specific key operations: ML-KEM
1835*/
1836
1837BOTAN_FFI_EXPORT(3, 6)
1838int botan_privkey_load_ml_kem(botan_privkey_t* key, const uint8_t privkey[], size_t key_len, const char* mlkem_mode);
1839
1840BOTAN_FFI_EXPORT(3, 6)
1841int botan_pubkey_load_ml_kem(botan_pubkey_t* key, const uint8_t pubkey[], size_t key_len, const char* mlkem_mode);
1842
1843/*
1844* Algorithm specific key operations: SLH-DSA
1845*/
1846
1847BOTAN_FFI_EXPORT(3, 6)
1848int botan_privkey_load_slh_dsa(botan_privkey_t* key, const uint8_t privkey[], size_t key_len, const char* slhdsa_mode);
1849
1850BOTAN_FFI_EXPORT(3, 6)
1851int botan_pubkey_load_slh_dsa(botan_pubkey_t* key, const uint8_t pubkey[], size_t key_len, const char* slhdsa_mode);
1852
1853/*
1854* Algorithm specific key operations: ECDSA and ECDH
1855*/
1856BOTAN_FFI_EXPORT(3, 2)
1858
1859BOTAN_FFI_EXPORT(2, 2)
1860int botan_privkey_load_ecdsa(botan_privkey_t* key, botan_mp_t scalar, const char* curve_name);
1861
1862BOTAN_FFI_EXPORT(2, 2)
1863int botan_pubkey_load_ecdsa(botan_pubkey_t* key, botan_mp_t public_x, botan_mp_t public_y, const char* curve_name);
1864
1865BOTAN_FFI_EXPORT(2, 2)
1866int botan_pubkey_load_ecdh(botan_pubkey_t* key, botan_mp_t public_x, botan_mp_t public_y, const char* curve_name);
1867
1868BOTAN_FFI_EXPORT(2, 2)
1869int botan_privkey_load_ecdh(botan_privkey_t* key, botan_mp_t scalar, const char* curve_name);
1870
1871BOTAN_FFI_EXPORT(2, 2)
1872int botan_pubkey_load_sm2(botan_pubkey_t* key, botan_mp_t public_x, botan_mp_t public_y, const char* curve_name);
1873
1874BOTAN_FFI_EXPORT(2, 2)
1875int botan_privkey_load_sm2(botan_privkey_t* key, botan_mp_t scalar, const char* curve_name);
1876
1877BOTAN_FFI_DEPRECATED("Use botan_pubkey_load_sm2")
1878BOTAN_FFI_EXPORT(2, 2)
1879int botan_pubkey_load_sm2_enc(botan_pubkey_t* key, botan_mp_t public_x, botan_mp_t public_y, const char* curve_name);
1880
1881BOTAN_FFI_DEPRECATED("Use botan_privkey_load_sm2")
1882BOTAN_FFI_EXPORT(2, 2)
1883int botan_privkey_load_sm2_enc(botan_privkey_t* key, botan_mp_t scalar, const char* curve_name);
1884
1885BOTAN_FFI_EXPORT(2, 3)
1887 uint8_t out[], size_t* out_len, const char* ident, const char* hash_algo, botan_pubkey_t key);
1888
1889/**
1890* View the uncompressed public point associated with the key
1891*/
1892BOTAN_FFI_EXPORT(3, 0)
1894
1895/*
1896* Public Key Encryption
1897*/
1898typedef struct botan_pk_op_encrypt_struct* botan_pk_op_encrypt_t;
1899
1900BOTAN_FFI_EXPORT(2, 0)
1901int botan_pk_op_encrypt_create(botan_pk_op_encrypt_t* op, botan_pubkey_t key, const char* padding, uint32_t flags);
1902
1903/**
1904* @return 0 if success, error if invalid object handle
1905*/
1907
1908BOTAN_FFI_EXPORT(2, 8)
1909int botan_pk_op_encrypt_output_length(botan_pk_op_encrypt_t op, size_t ptext_len, size_t* ctext_len);
1910
1911BOTAN_FFI_EXPORT(2, 0)
1913 botan_rng_t rng,
1914 uint8_t out[],
1915 size_t* out_len,
1916 const uint8_t plaintext[],
1917 size_t plaintext_len);
1918
1919/*
1920* Public Key Decryption
1921*/
1922typedef struct botan_pk_op_decrypt_struct* botan_pk_op_decrypt_t;
1923
1924BOTAN_FFI_EXPORT(2, 0)
1925int botan_pk_op_decrypt_create(botan_pk_op_decrypt_t* op, botan_privkey_t key, const char* padding, uint32_t flags);
1926
1927/**
1928* @return 0 if success, error if invalid object handle
1929*/
1931
1932BOTAN_FFI_EXPORT(2, 8)
1933int botan_pk_op_decrypt_output_length(botan_pk_op_decrypt_t op, size_t ctext_len, size_t* ptext_len);
1934
1935BOTAN_FFI_EXPORT(2, 0)
1937 botan_pk_op_decrypt_t op, uint8_t out[], size_t* out_len, const uint8_t ciphertext[], size_t ciphertext_len);
1938
1939/*
1940* Signature Generation
1941*/
1942
1943#define BOTAN_PUBKEY_DER_FORMAT_SIGNATURE 1
1944
1945typedef struct botan_pk_op_sign_struct* botan_pk_op_sign_t;
1946
1947BOTAN_FFI_EXPORT(2, 0)
1948int botan_pk_op_sign_create(botan_pk_op_sign_t* op, botan_privkey_t key, const char* hash_and_padding, uint32_t flags);
1949
1950/**
1951* @return 0 if success, error if invalid object handle
1952*/
1954
1956
1957BOTAN_FFI_EXPORT(2, 0) int botan_pk_op_sign_update(botan_pk_op_sign_t op, const uint8_t in[], size_t in_len);
1958
1959BOTAN_FFI_EXPORT(2, 0)
1960int botan_pk_op_sign_finish(botan_pk_op_sign_t op, botan_rng_t rng, uint8_t sig[], size_t* sig_len);
1961
1962/*
1963* Signature Verification
1964*/
1965typedef struct botan_pk_op_verify_struct* botan_pk_op_verify_t;
1966
1967BOTAN_FFI_EXPORT(2, 0)
1969 botan_pubkey_t key,
1970 const char* hash_and_padding,
1971 uint32_t flags);
1972
1973/**
1974* @return 0 if success, error if invalid object handle
1975*/
1977
1978BOTAN_FFI_EXPORT(2, 0) int botan_pk_op_verify_update(botan_pk_op_verify_t op, const uint8_t in[], size_t in_len);
1979BOTAN_FFI_EXPORT(2, 0) int botan_pk_op_verify_finish(botan_pk_op_verify_t op, const uint8_t sig[], size_t sig_len);
1980
1981/*
1982* Key Agreement
1983*/
1984typedef struct botan_pk_op_ka_struct* botan_pk_op_ka_t;
1985
1986BOTAN_FFI_EXPORT(2, 0)
1987int botan_pk_op_key_agreement_create(botan_pk_op_ka_t* op, botan_privkey_t key, const char* kdf, uint32_t flags);
1988
1989/**
1990* @return 0 if success, error if invalid object handle
1991*/
1993
1994BOTAN_FFI_EXPORT(2, 0) int botan_pk_op_key_agreement_export_public(botan_privkey_t key, uint8_t out[], size_t* out_len);
1995
1996BOTAN_FFI_EXPORT(3, 0)
1998
2000
2001BOTAN_FFI_EXPORT(2, 0)
2003 uint8_t out[],
2004 size_t* out_len,
2005 const uint8_t other_key[],
2006 size_t other_key_len,
2007 const uint8_t salt[],
2008 size_t salt_len);
2009
2010/*
2011* Key Encapsulation
2012*/
2013typedef struct botan_pk_op_kem_encrypt_struct* botan_pk_op_kem_encrypt_t;
2014
2015BOTAN_FFI_EXPORT(3, 0)
2017
2018/**
2019* @return 0 if success, error if invalid object handle
2020*/
2022
2023BOTAN_FFI_EXPORT(3, 0)
2025 size_t desired_shared_key_length,
2026 size_t* output_shared_key_length);
2027
2028BOTAN_FFI_EXPORT(3, 0)
2030 size_t* output_encapsulated_key_length);
2031
2032BOTAN_FFI_EXPORT(3, 0)
2034 botan_rng_t rng,
2035 const uint8_t salt[],
2036 size_t salt_len,
2037 size_t desired_shared_key_len,
2038 uint8_t shared_key[],
2039 size_t* shared_key_len,
2040 uint8_t encapsulated_key[],
2041 size_t* encapsulated_key_len);
2042
2043typedef struct botan_pk_op_kem_decrypt_struct* botan_pk_op_kem_decrypt_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 const uint8_t salt[],
2061 size_t salt_len,
2062 const uint8_t encapsulated_key[],
2063 size_t encapsulated_key_len,
2064 size_t desired_shared_key_len,
2065 uint8_t shared_key[],
2066 size_t* shared_key_len);
2067
2068/**
2069* Signature Scheme Utility Functions
2070*/
2071
2072BOTAN_FFI_EXPORT(2, 0) int botan_pkcs_hash_id(const char* hash_name, uint8_t pkcs_id[], size_t* pkcs_id_len);
2073
2074/*
2075* Always returns BOTAN_FFI_ERROR_NOT_IMPLEMENTED
2076*/
2077BOTAN_FFI_DEPRECATED("No longer implemented")
2078BOTAN_FFI_EXPORT(2, 0)
2080 botan_rng_t rng,
2081 const char* aead,
2082 const uint8_t pt[],
2083 size_t pt_len,
2084 const uint8_t ad[],
2085 size_t ad_len,
2086 uint8_t ct[],
2087 size_t* ct_len);
2088
2089/*
2090* Always returns BOTAN_FFI_ERROR_NOT_IMPLEMENTED
2091*/
2092BOTAN_FFI_DEPRECATED("No longer implemented")
2093BOTAN_FFI_EXPORT(2, 0)
2095 const char* aead,
2096 const uint8_t ct[],
2097 size_t ct_len,
2098 const uint8_t ad[],
2099 size_t ad_len,
2100 uint8_t pt[],
2101 size_t* pt_len);
2102
2103/*
2104* X.509 certificates
2105**************************/
2106
2107typedef struct botan_x509_cert_struct* botan_x509_cert_t;
2108
2109BOTAN_FFI_EXPORT(2, 0) int botan_x509_cert_load(botan_x509_cert_t* cert_obj, const uint8_t cert[], size_t cert_len);
2110BOTAN_FFI_EXPORT(2, 0) int botan_x509_cert_load_file(botan_x509_cert_t* cert_obj, const char* filename);
2111
2112/**
2113* @return 0 if success, error if invalid object handle
2114*/
2116
2118
2119/* Prefer botan_x509_cert_not_before and botan_x509_cert_not_after */
2120BOTAN_FFI_EXPORT(2, 0) int botan_x509_cert_get_time_starts(botan_x509_cert_t cert, char out[], size_t* out_len);
2121BOTAN_FFI_EXPORT(2, 0) int botan_x509_cert_get_time_expires(botan_x509_cert_t cert, char out[], size_t* out_len);
2122
2123BOTAN_FFI_EXPORT(2, 8) int botan_x509_cert_not_before(botan_x509_cert_t cert, uint64_t* time_since_epoch);
2124BOTAN_FFI_EXPORT(2, 8) int botan_x509_cert_not_after(botan_x509_cert_t cert, uint64_t* time_since_epoch);
2125
2126/* TODO(Botan4) this should use char for the out param */
2127BOTAN_FFI_EXPORT(2, 0)
2128int botan_x509_cert_get_fingerprint(botan_x509_cert_t cert, const char* hash, uint8_t out[], size_t* out_len);
2129
2130BOTAN_FFI_EXPORT(2, 0) int botan_x509_cert_get_serial_number(botan_x509_cert_t cert, uint8_t out[], size_t* out_len);
2131BOTAN_FFI_EXPORT(2, 0) int botan_x509_cert_get_authority_key_id(botan_x509_cert_t cert, uint8_t out[], size_t* out_len);
2132BOTAN_FFI_EXPORT(2, 0) int botan_x509_cert_get_subject_key_id(botan_x509_cert_t cert, uint8_t out[], size_t* out_len);
2133
2134BOTAN_FFI_EXPORT(2, 0) int botan_x509_cert_get_public_key_bits(botan_x509_cert_t cert, uint8_t out[], size_t* out_len);
2135
2136BOTAN_FFI_EXPORT(3, 0)
2138
2140
2141/* TODO(Botan4) this should use char for the out param */
2142BOTAN_FFI_EXPORT(2, 0)
2144 botan_x509_cert_t cert, const char* key, size_t index, uint8_t out[], size_t* out_len);
2145
2146/* TODO(Botan4) this should use char for the out param */
2147BOTAN_FFI_EXPORT(2, 0)
2149 botan_x509_cert_t cert, const char* key, size_t index, uint8_t out[], size_t* out_len);
2150
2151BOTAN_FFI_EXPORT(2, 0) int botan_x509_cert_to_string(botan_x509_cert_t cert, char out[], size_t* out_len);
2152
2153BOTAN_FFI_EXPORT(3, 0)
2155
2156/* Must match values of Key_Constraints in key_constraints.h */
2169
2170BOTAN_FFI_EXPORT(2, 0) int botan_x509_cert_allowed_usage(botan_x509_cert_t cert, unsigned int key_usage);
2171
2172/**
2173* Check if the certificate matches the specified hostname via alternative name or CN match.
2174* RFC 5280 wildcards also supported.
2175*/
2176BOTAN_FFI_EXPORT(2, 5) int botan_x509_cert_hostname_match(botan_x509_cert_t cert, const char* hostname);
2177
2178/**
2179* Returns 0 if the validation was successful, 1 if validation failed,
2180* and negative on error. A status code with details is written to
2181* *validation_result
2182*
2183* Intermediates or trusted lists can be null
2184* Trusted path can be null
2185*/
2186BOTAN_FFI_EXPORT(2, 8)
2187int botan_x509_cert_verify(int* validation_result,
2188 botan_x509_cert_t cert,
2189 const botan_x509_cert_t* intermediates,
2190 size_t intermediates_len,
2191 const botan_x509_cert_t* trusted,
2192 size_t trusted_len,
2193 const char* trusted_path,
2194 size_t required_strength,
2195 const char* hostname,
2196 uint64_t reference_time);
2197
2198/**
2199* Returns a pointer to a static character string explaining the status code,
2200* or else NULL if unknown.
2201*/
2202BOTAN_FFI_EXPORT(2, 8) const char* botan_x509_cert_validation_status(int code);
2203
2204/*
2205* X.509 CRL
2206**************************/
2207
2208typedef struct botan_x509_crl_struct* botan_x509_crl_t;
2209
2210BOTAN_FFI_EXPORT(2, 13) int botan_x509_crl_load_file(botan_x509_crl_t* crl_obj, const char* crl_path);
2211BOTAN_FFI_EXPORT(2, 13)
2212int botan_x509_crl_load(botan_x509_crl_t* crl_obj, const uint8_t crl_bits[], size_t crl_bits_len);
2213
2215
2216/**
2217 * Given a CRL and a certificate,
2218 * check if the certificate is revoked on that particular CRL
2219 */
2221
2222/**
2223 * Different flavor of `botan_x509_cert_verify`, supports revocation lists.
2224 * CRLs are passed as an array, same as intermediates and trusted CAs
2225 */
2226BOTAN_FFI_EXPORT(2, 13)
2227int botan_x509_cert_verify_with_crl(int* validation_result,
2228 botan_x509_cert_t cert,
2229 const botan_x509_cert_t* intermediates,
2230 size_t intermediates_len,
2231 const botan_x509_cert_t* trusted,
2232 size_t trusted_len,
2233 const botan_x509_crl_t* crls,
2234 size_t crls_len,
2235 const char* trusted_path,
2236 size_t required_strength,
2237 const char* hostname,
2238 uint64_t reference_time);
2239
2240/**
2241 * Key wrapping as per RFC 3394
2242 */
2243BOTAN_FFI_DEPRECATED("Use botan_nist_kw_enc")
2244BOTAN_FFI_EXPORT(2, 2)
2245int botan_key_wrap3394(const uint8_t key[],
2246 size_t key_len,
2247 const uint8_t kek[],
2248 size_t kek_len,
2249 uint8_t wrapped_key[],
2250 size_t* wrapped_key_len);
2251
2252BOTAN_FFI_DEPRECATED("Use botan_nist_kw_dec")
2253BOTAN_FFI_EXPORT(2, 2)
2254int botan_key_unwrap3394(const uint8_t wrapped_key[],
2255 size_t wrapped_key_len,
2256 const uint8_t kek[],
2257 size_t kek_len,
2258 uint8_t key[],
2259 size_t* key_len);
2260
2261BOTAN_FFI_EXPORT(3, 0)
2262int botan_nist_kw_enc(const char* cipher_algo,
2263 int padded,
2264 const uint8_t key[],
2265 size_t key_len,
2266 const uint8_t kek[],
2267 size_t kek_len,
2268 uint8_t wrapped_key[],
2269 size_t* wrapped_key_len);
2270
2271BOTAN_FFI_EXPORT(3, 0)
2272int botan_nist_kw_dec(const char* cipher_algo,
2273 int padded,
2274 const uint8_t wrapped_key[],
2275 size_t wrapped_key_len,
2276 const uint8_t kek[],
2277 size_t kek_len,
2278 uint8_t key[],
2279 size_t* key_len);
2280
2281/**
2282* HOTP
2283*/
2284
2285typedef struct botan_hotp_struct* botan_hotp_t;
2286
2287/**
2288* Initialize a HOTP instance
2289*/
2290BOTAN_FFI_EXPORT(2, 8)
2291int botan_hotp_init(botan_hotp_t* hotp, const uint8_t key[], size_t key_len, const char* hash_algo, size_t digits);
2292
2293/**
2294* Destroy a HOTP instance
2295* @return 0 if success, error if invalid object handle
2296*/
2297BOTAN_FFI_EXPORT(2, 8)
2299
2300/**
2301* Generate a HOTP code for the provided counter
2302*/
2303BOTAN_FFI_EXPORT(2, 8)
2304int botan_hotp_generate(botan_hotp_t hotp, uint32_t* hotp_code, uint64_t hotp_counter);
2305
2306/**
2307* Verify a HOTP code
2308*/
2309BOTAN_FFI_EXPORT(2, 8)
2311 botan_hotp_t hotp, uint64_t* next_hotp_counter, uint32_t hotp_code, uint64_t hotp_counter, size_t resync_range);
2312
2313/**
2314* TOTP
2315*/
2316
2317typedef struct botan_totp_struct* botan_totp_t;
2318
2319/**
2320* Initialize a TOTP instance
2321*/
2322BOTAN_FFI_EXPORT(2, 8)
2323int botan_totp_init(
2324 botan_totp_t* totp, const uint8_t key[], size_t key_len, const char* hash_algo, size_t digits, size_t time_step);
2325
2326/**
2327* Destroy a TOTP instance
2328* @return 0 if success, error if invalid object handle
2329*/
2330BOTAN_FFI_EXPORT(2, 8)
2332
2333/**
2334* Generate a TOTP code for the provided timestamp
2335* @param totp the TOTP object
2336* @param totp_code the OTP code will be written here
2337* @param timestamp the current local timestamp
2338*/
2339BOTAN_FFI_EXPORT(2, 8)
2340int botan_totp_generate(botan_totp_t totp, uint32_t* totp_code, uint64_t timestamp);
2341
2342/**
2343* Verify a TOTP code
2344* @param totp the TOTP object
2345* @param totp_code the presented OTP
2346* @param timestamp the current local timestamp
2347* @param acceptable_clock_drift specifies the acceptable amount
2348* of clock drift (in terms of time steps) between the two hosts.
2349*/
2350BOTAN_FFI_EXPORT(2, 8)
2351int botan_totp_check(botan_totp_t totp, uint32_t totp_code, uint64_t timestamp, size_t acceptable_clock_drift);
2352
2353/**
2354* Format Preserving Encryption
2355*/
2356
2357typedef struct botan_fpe_struct* botan_fpe_t;
2358
2359#define BOTAN_FPE_FLAG_FE1_COMPAT_MODE 1
2360
2361BOTAN_FFI_EXPORT(2, 8)
2363 botan_fpe_t* fpe, botan_mp_t n, const uint8_t key[], size_t key_len, size_t rounds, uint32_t flags);
2364
2365/**
2366* @return 0 if success, error if invalid object handle
2367*/
2368BOTAN_FFI_EXPORT(2, 8)
2370
2371BOTAN_FFI_EXPORT(2, 8)
2372int botan_fpe_encrypt(botan_fpe_t fpe, botan_mp_t x, const uint8_t tweak[], size_t tweak_len);
2373
2374BOTAN_FFI_EXPORT(2, 8)
2375int botan_fpe_decrypt(botan_fpe_t fpe, botan_mp_t x, const uint8_t tweak[], size_t tweak_len);
2376
2377/**
2378* SRP-6 Server Session type
2379*/
2380typedef struct botan_srp6_server_session_struct* botan_srp6_server_session_t;
2381
2382/**
2383* Initialize an SRP-6 server session object
2384* @param srp6 SRP-6 server session object
2385*/
2386BOTAN_FFI_EXPORT(3, 0)
2388
2389/**
2390* Frees all resources of the SRP-6 server session object
2391* @param srp6 SRP-6 server session object
2392* @return 0 if success, error if invalid object handle
2393*/
2394BOTAN_FFI_EXPORT(3, 0)
2396
2397/**
2398* SRP-6 Server side step 1
2399* @param srp6 SRP-6 server session object
2400* @param verifier the verification value saved from client registration
2401* @param verifier_len SRP-6 verifier value length
2402* @param group_id the SRP group id
2403* @param hash_id the SRP hash in use
2404* @param rng_obj a random number generator object
2405* @param B_pub out buffer to store the SRP-6 B value
2406* @param B_pub_len SRP-6 B value length
2407* @return 0 on success, negative on failure
2408*/
2409BOTAN_FFI_EXPORT(3, 0)
2411 const uint8_t verifier[],
2412 size_t verifier_len,
2413 const char* group_id,
2414 const char* hash_id,
2415 botan_rng_t rng_obj,
2416 uint8_t B_pub[],
2417 size_t* B_pub_len);
2418
2419/**
2420* SRP-6 Server side step 2
2421* @param srp6 SRP-6 server session object
2422* @param A the client's value
2423* @param A_len the client's value length
2424* @param key out buffer to store the symmetric key value
2425* @param key_len symmetric key length
2426* @return 0 on success, negative on failure
2427*/
2428BOTAN_FFI_EXPORT(3, 0)
2430 botan_srp6_server_session_t srp6, const uint8_t A[], size_t A_len, uint8_t key[], size_t* key_len);
2431
2432/**
2433* Generate a new SRP-6 verifier
2434* @param identifier a username or other client identifier
2435* @param password the secret used to authenticate user
2436* @param salt a randomly chosen value, at least 128 bits long
2437* @param salt_len the length of salt
2438* @param group_id specifies the shared SRP group
2439* @param hash_id specifies a secure hash function
2440* @param verifier out buffer to store the SRP-6 verifier value
2441* @param verifier_len SRP-6 verifier value length
2442* @return 0 on success, negative on failure
2443*/
2444BOTAN_FFI_EXPORT(3, 0)
2445int botan_srp6_generate_verifier(const char* identifier,
2446 const char* password,
2447 const uint8_t salt[],
2448 size_t salt_len,
2449 const char* group_id,
2450 const char* hash_id,
2451 uint8_t verifier[],
2452 size_t* verifier_len);
2453
2454/**
2455* SRP6a Client side
2456* @param username the username we are attempting login for
2457* @param password the password we are attempting to use
2458* @param group_id specifies the shared SRP group
2459* @param hash_id specifies a secure hash function
2460* @param salt is the salt value sent by the server
2461* @param salt_len the length of salt
2462* @param B is the server's public value
2463* @param B_len is the server's public value length
2464* @param rng_obj is a random number generator object
2465* @param A out buffer to store the SRP-6 A value
2466* @param A_len SRP-6 A verifier value length
2467* @param K out buffer to store the symmetric value
2468* @param K_len symmetric key length
2469* @return 0 on success, negative on failure
2470*/
2471BOTAN_FFI_EXPORT(3, 0)
2472int botan_srp6_client_agree(const char* username,
2473 const char* password,
2474 const char* group_id,
2475 const char* hash_id,
2476 const uint8_t salt[],
2477 size_t salt_len,
2478 const uint8_t B[],
2479 size_t B_len,
2480 botan_rng_t rng_obj,
2481 uint8_t A[],
2482 size_t* A_len,
2483 uint8_t K[],
2484 size_t* K_len);
2485
2486/**
2487* Return the size, in bytes, of the prime associated with group_id
2488*/
2489BOTAN_FFI_EXPORT(3, 0)
2490int botan_srp6_group_size(const char* group_id, size_t* group_p_bytes);
2491
2492/**
2493 * ZFEC
2494 */
2495
2496/**
2497 * Encode some bytes with certain ZFEC parameters.
2498 *
2499 * @param K the number of shares needed for recovery
2500 * @param N the number of shares generated
2501 * @param input the data to FEC
2502 * @param size the length in bytes of input, which must be a multiple of K
2503 *
2504 * @param outputs An out parameter pointing to a fully allocated array of size
2505 * [N][size / K]. For all n in range, an encoded block will be
2506 * written to the memory starting at outputs[n][0].
2507 *
2508 * @return 0 on success, negative on failure
2509 */
2510BOTAN_FFI_EXPORT(3, 0)
2511int botan_zfec_encode(size_t K, size_t N, const uint8_t* input, size_t size, uint8_t** outputs);
2512
2513/**
2514 * Decode some previously encoded shares using certain ZFEC parameters.
2515 *
2516 * @param K the number of shares needed for recovery
2517 * @param N the total number of shares
2518 *
2519 * @param indexes The index into the encoder's outputs for the corresponding
2520 * element of the inputs array. Must be of length K.
2521 *
2522 * @param inputs K previously encoded shares to decode
2523 * @param shareSize the length in bytes of each input
2524 *
2525 * @param outputs An out parameter pointing to a fully allocated array of size
2526 * [K][shareSize]. For all k in range, a decoded block will
2527 * written to the memory starting at outputs[k][0].
2528 *
2529 * @return 0 on success, negative on failure
2530 */
2531BOTAN_FFI_EXPORT(3, 0)
2533 size_t K, size_t N, const size_t* indexes, uint8_t* const* inputs, size_t shareSize, uint8_t** outputs);
2534
2535/**
2536* TPM2 context
2537*/
2538typedef struct botan_tpm2_ctx_struct* botan_tpm2_ctx_t;
2539
2540/**
2541* TPM2 session
2542*/
2543typedef struct botan_tpm2_session_struct* botan_tpm2_session_t;
2544
2545/**
2546* TPM2 crypto backend state object
2547*/
2548typedef struct botan_tpm2_crypto_backend_state_struct* botan_tpm2_crypto_backend_state_t;
2549
2550struct ESYS_CONTEXT;
2551
2552/**
2553* Checks if Botan's TSS2 crypto backend can be used in this build
2554* @returns 1 if the crypto backend can be enabled
2555*/
2556BOTAN_FFI_EXPORT(3, 6)
2558
2559/**
2560* Initialize a TPM2 context
2561* @param ctx_out output TPM2 context
2562* @param tcti_nameconf TCTI config (may be nullptr)
2563* @return 0 on success
2564*/
2565BOTAN_FFI_EXPORT(3, 6) int botan_tpm2_ctx_init(botan_tpm2_ctx_t* ctx_out, const char* tcti_nameconf);
2566
2567/**
2568* Initialize a TPM2 context
2569* @param ctx_out output TPM2 context
2570* @param tcti_name TCTI name (may be nullptr)
2571* @param tcti_conf TCTI config (may be nullptr)
2572* @return 0 on success
2573*/
2574BOTAN_FFI_EXPORT(3, 6)
2575int botan_tpm2_ctx_init_ex(botan_tpm2_ctx_t* ctx_out, const char* tcti_name, const char* tcti_conf);
2576
2577/**
2578* Wrap an existing ESYS_CONTEXT for use in Botan.
2579* Note that destroying the created botan_tpm2_ctx_t won't
2580* finalize @p esys_ctx
2581* @param ctx_out output TPM2 context
2582* @param esys_ctx ESYS_CONTEXT to wrap
2583* @return 0 on success
2584*/
2585BOTAN_FFI_EXPORT(3, 7)
2586int botan_tpm2_ctx_from_esys(botan_tpm2_ctx_t* ctx_out, struct ESYS_CONTEXT* esys_ctx);
2587
2588/**
2589* Enable Botan's TSS2 crypto backend that replaces the cryptographic functions
2590* required for the communication with the TPM with implementations provided
2591* by Botan instead of using TSS' defaults OpenSSL or mbedTLS.
2592* Note that the provided @p rng should not be dependent on the TPM and the
2593* caller must ensure that it remains usable for the lifetime of the @p ctx.
2594* @param ctx TPM2 context
2595* @param rng random number generator to be used by the crypto backend
2596*/
2597BOTAN_FFI_EXPORT(3, 6)
2599
2600/**
2601* Frees all resouces of a TPM2 context
2602* @param ctx TPM2 context
2603* @return 0 on success
2604*/
2606
2607/**
2608* Use this if you just need Botan's crypto backend but do not want to wrap any
2609* other ESYS functionality using Botan's TPM2 wrapper.
2610* A Crypto Backend State is created that the user needs to keep alive for as
2611* long as the crypto backend is used and needs to be destroyed after.
2612* Note that the provided @p rng should not be dependent on the TPM and the
2613* caller must ensure that it remains usable for the lifetime of the @p esys_ctx.
2614* @param cbs_out To be created Crypto Backend State
2615* @param esys_ctx TPM2 context
2616* @param rng random number generator to be used by the crypto backend
2617*/
2618BOTAN_FFI_EXPORT(3, 7)
2620 struct ESYS_CONTEXT* esys_ctx,
2621 botan_rng_t rng);
2622
2623/**
2624* Frees all resouces of a TPM2 Crypto Callback State
2625* Note that this does not attempt to de-register the crypto backend,
2626* it just frees the resource pointed to by @p cbs. Use the ESAPI function
2627* ``Esys_SetCryptoCallbacks(ctx, nullptr)`` to deregister manually.
2628* @param cbs TPM2 Crypto Callback State
2629* @return 0 on success
2630*/
2632
2633/**
2634* Initialize a random number generator object via TPM2
2635* @param rng_out rng object to create
2636* @param ctx TPM2 context
2637* @param s1 the first session to use (optional, may be nullptr)
2638* @param s2 the second session to use (optional, may be nullptr)
2639* @param s3 the third session to use (optional, may be nullptr)
2640*/
2641BOTAN_FFI_EXPORT(3, 6)
2642int botan_tpm2_rng_init(botan_rng_t* rng_out,
2643 botan_tpm2_ctx_t ctx,
2647
2648/**
2649* Create an unauthenticated session for use with TPM2
2650* @param session_out the session object to create
2651* @param ctx TPM2 context
2652*/
2653BOTAN_FFI_EXPORT(3, 6)
2655
2656/**
2657* Create an unauthenticated session for use with TPM2
2658* @param session the session object to destroy
2659*/
2660BOTAN_FFI_EXPORT(3, 6)
2662
2663/* NOLINTEND(*-macro-usage,*-misplaced-const) */
2664
2665#ifdef __cplusplus
2666}
2667#endif
2668
2669#endif
uint32_t botan_version_datestamp()
Definition ffi.cpp:297
int botan_same_mem(const uint8_t *x, const uint8_t *y, size_t len)
Definition ffi.cpp:307
const char * botan_version_string()
Definition ffi.cpp:281
int botan_base64_decode(const char *base64_str, size_t in_len, uint8_t *out, size_t *out_len)
Definition ffi.cpp:338
uint32_t botan_version_patch()
Definition ffi.cpp:293
int botan_base64_encode(const uint8_t *in, size_t len, char *out, size_t *out_len)
Definition ffi.cpp:331
int botan_scrub_mem(void *mem, size_t bytes)
Definition ffi.cpp:311
int botan_hex_encode(const uint8_t *in, size_t len, char *out, uint32_t flags)
Definition ffi.cpp:316
uint32_t botan_version_major()
Definition ffi.cpp:285
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:289
int botan_constant_time_compare(const uint8_t *x, const uint8_t *y, size_t len)
Definition ffi.cpp:301
int botan_hex_decode(const char *hex_str, size_t in_len, uint8_t *out, size_t *out_len)
Definition ffi.cpp:324
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:206
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:240
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:168
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:103
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:2043
int botan_privkey_check_key(botan_privkey_t key, botan_rng_t rng, uint32_t flags)
Definition ffi_pkey.cpp:159
int botan_privkey_create_elgamal(botan_privkey_t *key, botan_rng_t rng, size_t pbits, size_t qbits)
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:231
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:210
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:1537
int botan_pubkey_load_dh(botan_pubkey_t *key, botan_mp_t p, botan_mp_t g, botan_mp_t y)
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:118
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:201
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:92
int botan_mp_to_uint32(botan_mp_t mp, uint32_t *val)
Definition ffi_mp.cpp:107
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:113
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:2380
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:1922
struct botan_mac_struct * botan_mac_t
Definition ffi.h:461
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:184
struct botan_asn1_oid_struct * botan_asn1_oid_t
Definition ffi.h:1121
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:1304
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_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:2208
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:2543
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:260
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_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:1898
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:138
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:141
int botan_mp_swap(botan_mp_t x, botan_mp_t y)
Definition ffi_mp.cpp:196
struct botan_totp_struct * botan_totp_t
Definition ffi.h:2317
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:114
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:220
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:227
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_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:176
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:252
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:2013
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:180
int botan_mp_mod_inverse(botan_mp_t out, botan_mp_t in, botan_mp_t modulus)
Definition ffi_mp.cpp:214
int botan_mp_cmp(int *result, botan_mp_t x, botan_mp_t y)
Definition ffi_mp.cpp:192
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_pubkey_load_elgamal(botan_pubkey_t *key, botan_mp_t p, botan_mp_t g, botan_mp_t y)
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:2285
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:236
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:1170
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_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:244
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:148
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_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:2107
int botan_mp_num_bits(botan_mp_t n, size_t *bits)
Definition ffi_mp.cpp:256
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:2538
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:158
struct botan_pk_op_ka_struct * botan_pk_op_ka_t
Definition ffi.h:1984
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:1945
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_privkey_load_elgamal(botan_privkey_t *key, botan_mp_t p, botan_mp_t g, botan_mp_t x)
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:2157
@ KEY_ENCIPHERMENT
Definition ffi.h:2161
@ NO_CONSTRAINTS
Definition ffi.h:2158
@ CRL_SIGN
Definition ffi.h:2165
@ DIGITAL_SIGNATURE
Definition ffi.h:2159
@ KEY_AGREEMENT
Definition ffi.h:2163
@ DATA_ENCIPHERMENT
Definition ffi.h:2162
@ KEY_CERT_SIGN
Definition ffi.h:2164
@ ENCIPHER_ONLY
Definition ffi.h:2166
@ NON_REPUDIATION
Definition ffi.h:2160
@ DECIPHER_ONLY
Definition ffi.h:2167
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_privkey_create_dsa(botan_privkey_t *key, botan_rng_t rng, size_t pbits, size_t qbits)
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:2548
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:1965
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:188
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_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:128
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:2357
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_mp_to_str(botan_mp_t mp, uint8_t base, char *out, size_t *out_len)
Definition ffi_mp.cpp:91
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:248
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])