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