Crypt-Sodium-XS
view release on metacpan or search on metacpan
inc/stream.xs view on Meta::CPAN
=for documentation
stream is provided for completeness, but should not be used without very good
understanding. it is not authenticated. better options are secretbox or box.
salsa208 not implemented (deprecated in libsodium)
libsodium does not provide interface to set internal counter when using stream
function (only for stream_*xor_ic). always starts at 0 and is incremented as
needed internally for output size.
=cut
MODULE = Crypt::Sodium::XS PACKAGE = Crypt::Sodium::XS::stream
void _define_constants()
PREINIT:
HV *stash = gv_stashpv("Crypt::Sodium::XS::stream", 0);
PPCODE:
newCONSTSUB(stash, "stream_KEYBYTES", newSVuv(crypto_stream_KEYBYTES));
newCONSTSUB(stash, "stream_chacha20_KEYBYTES",
newSVuv(crypto_stream_chacha20_KEYBYTES));
newCONSTSUB(stash, "stream_chacha20_ietf_KEYBYTES",
newSVuv(crypto_stream_chacha20_ietf_KEYBYTES));
newCONSTSUB(stash, "stream_salsa20_KEYBYTES",
newSVuv(crypto_stream_salsa20_KEYBYTES));
newCONSTSUB(stash, "stream_salsa2012_KEYBYTES",
newSVuv(crypto_stream_salsa2012_KEYBYTES));
newCONSTSUB(stash, "stream_xchacha20_KEYBYTES",
newSVuv(crypto_stream_xchacha20_KEYBYTES));
newCONSTSUB(stash, "stream_xsalsa20_KEYBYTES",
newSVuv(crypto_stream_xsalsa20_KEYBYTES));
newCONSTSUB(stash, "stream_NONCEBYTES", newSVuv(crypto_stream_NONCEBYTES));
newCONSTSUB(stash, "stream_chacha20_NONCEBYTES",
newSVuv(crypto_stream_chacha20_NONCEBYTES));
newCONSTSUB(stash, "stream_chacha20_ietf_NONCEBYTES",
newSVuv(crypto_stream_chacha20_ietf_NONCEBYTES));
newCONSTSUB(stash, "stream_salsa20_NONCEBYTES",
newSVuv(crypto_stream_salsa20_NONCEBYTES));
newCONSTSUB(stash, "stream_salsa2012_NONCEBYTES",
newSVuv(crypto_stream_salsa2012_NONCEBYTES));
newCONSTSUB(stash, "stream_xchacha20_NONCEBYTES",
newSVuv(crypto_stream_xchacha20_NONCEBYTES));
newCONSTSUB(stash, "stream_xsalsa20_NONCEBYTES",
newSVuv(crypto_stream_xsalsa20_NONCEBYTES));
newCONSTSUB(stash, "stream_MESSAGEBYTES_MAX",
newSVuv(crypto_stream_MESSAGEBYTES_MAX));
newCONSTSUB(stash, "stream_chacha20_MESSAGEBYTES_MAX",
newSVuv(crypto_stream_chacha20_MESSAGEBYTES_MAX));
newCONSTSUB(stash, "stream_chacha20_ietf_MESSAGEBYTES_MAX",
newSVuv(crypto_stream_chacha20_ietf_MESSAGEBYTES_MAX));
newCONSTSUB(stash, "stream_salsa20_MESSAGEBYTES_MAX",
newSVuv(crypto_stream_salsa20_MESSAGEBYTES_MAX));
newCONSTSUB(stash, "stream_salsa2012_MESSAGEBYTES_MAX",
newSVuv(crypto_stream_salsa2012_MESSAGEBYTES_MAX));
newCONSTSUB(stash, "stream_xchacha20_MESSAGEBYTES_MAX",
newSVuv(crypto_stream_xchacha20_MESSAGEBYTES_MAX));
newCONSTSUB(stash, "stream_xsalsa20_MESSAGEBYTES_MAX",
newSVuv(crypto_stream_xsalsa20_MESSAGEBYTES_MAX));
newCONSTSUB(stash, "stream_PRIMITIVE", newSVpvs(crypto_stream_PRIMITIVE));
SV * stream(STRLEN out_len, SV * nonce, SV * key)
ALIAS:
stream_chacha20 = 1
stream_chacha20_ietf = 2
stream_salsa20 = 3
stream_salsa2012 = 4
stream_xchacha20 = 5
stream_xsalsa20 = 6
PREINIT:
protmem *key_pm = NULL;
unsigned char *nonce_buf, *key_buf, *out_buf;
STRLEN nonce_len, key_len, nonce_req_len, key_req_len;
int (*func)(unsigned char *, unsigned long long,
const unsigned char *, const unsigned char *);
CODE:
( run in 0.721 second using v1.01-cache-2.11-cpan-71847e10f99 )