diff --git a/extra/sodium/ffi/ffi.factor b/extra/sodium/ffi/ffi.factor index 044d0d8386..58b5887474 100644 --- a/extra/sodium/ffi/ffi.factor +++ b/extra/sodium/ffi/ffi.factor @@ -53,3 +53,25 @@ FUNCTION: void sodium_free ( void* ptr ) FUNCTION: int sodium_mprotect_noaccess ( void* ptr ) FUNCTION: int sodium_mprotect_readonly ( void* ptr ) FUNCTION: int sodium_mprotect_readwrite ( void* ptr ) + +! crypto_generichash_H +TYPEDEF: void* crypto_generichash_state +FUNCTION: size_t crypto_generichash_bytes_min ( ) +FUNCTION: size_t crypto_generichash_bytes_max ( ) +FUNCTION: size_t crypto_generichash_bytes ( ) +FUNCTION: size_t crypto_generichash_keybytes_min ( ) +FUNCTION: size_t crypto_generichash_keybytes_max ( ) +FUNCTION: size_t crypto_generichash_keybytes ( ) +FUNCTION: char* crypto_generichash_primitive ( ) +FUNCTION: size_t crypto_generichash_statebytes ( ) +FUNCTION: int crypto_generichash ( + uchar* out, size_t outlen, + uchar* in, ulonglong inlen, + uchar* key, size_t keylen ) +FUNCTION: int crypto_generichash_init ( + crypto_generichash_state* state, + uchar* key, size_t keylen, size_t outlen ) +FUNCTION: int crypto_generichash_update ( + crypto_generichash_state* state, uchar* in, ulonglong inlen ) +FUNCTION: int crypto_generichash_final ( + crypto_generichash_state* state, uchar* out, size_t outlen ) diff --git a/extra/sodium/sodium.factor b/extra/sodium/sodium.factor index a495f5d117..490eb8d068 100644 --- a/extra/sodium/sodium.factor +++ b/extra/sodium/sodium.factor @@ -26,4 +26,7 @@ ERROR: call-fail ; : crypto-pwhash-str-verify ( str password -- bool ) [ utf8 encode ] bi@ dup length crypto_pwhash_str_verify 0 = ; +: crypto-generichash ( out-bytes in-bytes key-bytes/f -- out-bytes' ) + [ dup ] 2dip [ dup length ] tri@ crypto_generichash check0 ; + [ sodium-init ] "sodium" add-startup-hook