crypto_kdf_hkdf_sha256.h
1 #ifndef crypto_kdf_hkdf_sha256_H 2 #define crypto_kdf_hkdf_sha256_H 3 4 #include <stddef.h> 5 #include <stdint.h> 6 #include <stdlib.h> 7 8 #include <sodium.h> 9 //#include "crypto_kdf.h" 10 //#include "crypto_auth_hmacsha256.h" 11 //#include "export.h" 12 13 #ifdef __cplusplus 14 # ifdef __GNUC__ 15 # pragma GCC diagnostic ignored "-Wlong-long" 16 # endif 17 extern "C" { 18 #endif 19 20 #define crypto_kdf_hkdf_sha256_KEYBYTES crypto_auth_hmacsha256_BYTES 21 SODIUM_EXPORT 22 size_t crypto_kdf_hkdf_sha256_keybytes(void); 23 24 #define crypto_kdf_hkdf_sha256_BYTES_MIN 0U 25 SODIUM_EXPORT 26 size_t crypto_kdf_hkdf_sha256_bytes_min(void); 27 28 #define crypto_kdf_hkdf_sha256_BYTES_MAX (0xff * crypto_auth_hmacsha256_BYTES) 29 SODIUM_EXPORT 30 size_t crypto_kdf_hkdf_sha256_bytes_max(void); 31 32 SODIUM_EXPORT 33 int crypto_kdf_hkdf_sha256_extract(unsigned char prk[crypto_kdf_hkdf_sha256_KEYBYTES], 34 const unsigned char *salt, size_t salt_len, 35 const unsigned char *ikm, size_t ikm_len) 36 __attribute__ ((nonnull(4))); 37 38 SODIUM_EXPORT 39 void crypto_kdf_hkdf_sha256_keygen(unsigned char prk[crypto_kdf_hkdf_sha256_KEYBYTES]); 40 41 SODIUM_EXPORT 42 int crypto_kdf_hkdf_sha256_expand(unsigned char *out, size_t out_len, 43 const char *ctx, size_t ctx_len, 44 const unsigned char prk[crypto_kdf_hkdf_sha256_KEYBYTES]) 45 __attribute__ ((nonnull(1))); 46 47 /* ------------------------------------------------------------------------- */ 48 49 typedef struct crypto_kdf_hkdf_sha256_state { 50 crypto_auth_hmacsha256_state st; 51 } crypto_kdf_hkdf_sha256_state; 52 53 SODIUM_EXPORT 54 size_t crypto_kdf_hkdf_sha256_statebytes(void); 55 56 SODIUM_EXPORT 57 int crypto_kdf_hkdf_sha256_extract_init(crypto_kdf_hkdf_sha256_state *state, 58 const unsigned char *salt, size_t salt_len) 59 __attribute__ ((nonnull(1))); 60 61 SODIUM_EXPORT 62 int crypto_kdf_hkdf_sha256_extract_update(crypto_kdf_hkdf_sha256_state *state, 63 const unsigned char *ikm, size_t ikm_len) 64 __attribute__ ((nonnull)); 65 66 SODIUM_EXPORT 67 int crypto_kdf_hkdf_sha256_extract_final(crypto_kdf_hkdf_sha256_state *state, 68 unsigned char prk[crypto_kdf_hkdf_sha256_KEYBYTES]) 69 __attribute__ ((nonnull)); 70 71 #ifdef __cplusplus 72 } 73 #endif 74 75 #endif