Branch Coverage

Sodium.xs
Criterion Covered Total %
branch 597 1018 58.6


line true false branch
301 0 116007 if ( bl == NULL ) {
307 0 116007 if ( bl->bytes == NULL ) {
327 114521 0 if ( (default_locked = get_sv("Data::BytesLocker::DEFAULT_LOCKED", 0)) ) {
328 13 114508 if ( SvTRUE(default_locked) ) {
331 0 13 if ( rc != 0 ) {
339 0 0 if ( rc != 0 ) {
360 0 443511 if (!sv_derived_from(sv, "Data::BytesLocker"))
363 443511 0 for (mg = SvMAGIC(SvRV(sv)); mg; mg = mg->mg_moremagic) {
364 443511 0 if (mg->mg_type == PERL_MAGIC_ext && mg->mg_virtual == &vtbl_byteslocker) {
443511 0 if (mg->mg_type == PERL_MAGIC_ext && mg->mg_virtual == &vtbl_byteslocker) {
378 0 384 if ( pk == NULL ) {
384 0 384 if ( pk->ctx == NULL ) {
405 384 0 if ( (default_locked = get_sv("Data::BytesLocker::DEFAULT_LOCKED", 0)) ) {
406 0 384 if ( SvTRUE(default_locked) ) {
409 0 0 if ( rc != 0 ) {
432 0 1160 if (!sv_derived_from(sv, "Crypt::NaCl::Sodium::aead::aes256gcmstate"))
435 1160 0 for (mg = SvMAGIC(SvRV(sv)); mg; mg = mg->mg_moremagic) {
436 1160 0 if (mg->mg_type == PERL_MAGIC_ext && mg->mg_virtual == &vtbl_aead_aes256gcmstate) {
1160 0 if (mg->mg_type == PERL_MAGIC_ext && mg->mg_virtual == &vtbl_aead_aes256gcmstate) {
471 0 133067 if (!sv_derived_from(sv, "Crypt::NaCl::Sodium::generichash::stream"))
474 133067 0 for (mg = SvMAGIC(SvRV(sv)); mg; mg = mg->mg_moremagic) {
475 133067 0 if (mg->mg_type == PERL_MAGIC_ext && mg->mg_virtual == &vtbl_generichash) {
133067 0 if (mg->mg_type == PERL_MAGIC_ext && mg->mg_virtual == &vtbl_generichash) {
510 0 365 if (!sv_derived_from(sv, "Crypt::NaCl::Sodium::hash::sha256stream"))
513 365 0 for (mg = SvMAGIC(SvRV(sv)); mg; mg = mg->mg_moremagic) {
514 365 0 if (mg->mg_type == PERL_MAGIC_ext && mg->mg_virtual == &vtbl_hash_sha256) {
365 0 if (mg->mg_type == PERL_MAGIC_ext && mg->mg_virtual == &vtbl_hash_sha256) {
549 0 365 if (!sv_derived_from(sv, "Crypt::NaCl::Sodium::hash::sha512stream"))
552 365 0 for (mg = SvMAGIC(SvRV(sv)); mg; mg = mg->mg_moremagic) {
553 365 0 if (mg->mg_type == PERL_MAGIC_ext && mg->mg_virtual == &vtbl_hash_sha512) {
365 0 if (mg->mg_type == PERL_MAGIC_ext && mg->mg_virtual == &vtbl_hash_sha512) {
588 0 643 if (!sv_derived_from(sv, "Crypt::NaCl::Sodium::auth::hmacsha256stream"))
591 643 0 for (mg = SvMAGIC(SvRV(sv)); mg; mg = mg->mg_moremagic) {
592 643 0 if (mg->mg_type == PERL_MAGIC_ext && mg->mg_virtual == &vtbl_auth_hmacsha256) {
643 0 if (mg->mg_type == PERL_MAGIC_ext && mg->mg_virtual == &vtbl_auth_hmacsha256) {
627 0 643 if (!sv_derived_from(sv, "Crypt::NaCl::Sodium::auth::hmacsha512stream"))
630 643 0 for (mg = SvMAGIC(SvRV(sv)); mg; mg = mg->mg_moremagic) {
631 643 0 if (mg->mg_type == PERL_MAGIC_ext && mg->mg_virtual == &vtbl_auth_hmacsha512) {
643 0 if (mg->mg_type == PERL_MAGIC_ext && mg->mg_virtual == &vtbl_auth_hmacsha512) {
666 0 675 if (!sv_derived_from(sv, "Crypt::NaCl::Sodium::auth::hmacsha512256stream"))
669 675 0 for (mg = SvMAGIC(SvRV(sv)); mg; mg = mg->mg_moremagic) {
670 675 0 if (mg->mg_type == PERL_MAGIC_ext && mg->mg_virtual == &vtbl_auth_hmacsha512256) {
675 0 if (mg->mg_type == PERL_MAGIC_ext && mg->mg_virtual == &vtbl_auth_hmacsha512256) {
705 0 32 if (!sv_derived_from(sv, "Crypt::NaCl::Sodium::onetimeauth::stream"))
708 32 0 for (mg = SvMAGIC(SvRV(sv)); mg; mg = mg->mg_moremagic) {
709 32 0 if (mg->mg_type == PERL_MAGIC_ext && mg->mg_virtual == &vtbl_onetimeauth) {
32 0 if (mg->mg_type == PERL_MAGIC_ext && mg->mg_virtual == &vtbl_onetimeauth) {
724 0 54 if ( sodium_init() == -1 )
751 0 1024 if (right_len > left_len) {
755 0 1024 if (copy == NULL) {
792 0 1005 if ( GIMME_V == G_VOID ) {
798 2 1003 if ( length == 0 ) {
799 1 1 if ( left_len != right_len ) {
804 1 1002 if ( length > left_len ) {
807 1 1001 else if ( length > right_len ) {
812 1 1001 if ( sodium_memcmp(left_buf, right_buf, length) == 0 ) {
831 0 2004 if ( GIMME_V == G_VOID ) {
837 1 2003 if ( length == 0 ) {
838 1 0 if ( left_len != right_len ) {
843 1 2002 if ( length > left_len ) {
846 1 2001 else if ( length > right_len ) {
862 5 5 for ( i = 0; i < items; i++ ) {
863 0 5 if (sv_derived_from(ST(i), "Data::BytesLocker")) {
881 2 1 for ( i = 0; i < items; i++ ) {
894 122711 80 if ( items == 1 ) {
917 1 34194 if ( len < 1 ) {
942 0 5541 if ( bin_len > SIZE_MAX / 2 ) { /* avoid overflow */
947 0 5541 if ( hex == NULL ) {
975 5682 0 if (SvOK(hex_sv) && SvPOK(hex_sv)) {
5682 0 if (SvOK(hex_sv) && SvPOK(hex_sv)) {
977 156 5526 if (hex_len == 0) {
984 7 5519 if (items > 1) {
985 0 7 if ((items + 1) % 2 != 0) {
988 8 7 for (i = 1; i < items; i += 2) {
989 8 0 if (!SvOK(ST(i)) || !SvPOK(ST(i)))
0 8 if (!SvOK(ST(i)) || !SvPOK(ST(i)))
992 4 4 if (keylen == 6 && strnEQ(key, "ignore", 6)) {
4 0 if (keylen == 6 && strnEQ(key, "ignore", 6)) {
993 4 0 if (SvOK(ST(i + 1)) && SvPOK(ST(i + 1))) {
4 0 if (SvOK(ST(i + 1)) && SvPOK(ST(i + 1))) {
995 0 4 if (keylen < 1 && ignore != NULL) {
0 0 if (keylen < 1 && ignore != NULL) {
999 4 0 } else if (keylen == 7 && strnEQ(key, "max_len", 7)) {
4 0 } else if (keylen == 7 && strnEQ(key, "max_len", 7)) {
1000 4 0 if (SvOK(ST(i + 1)) && (SvIOK(ST(i + 1)) || SvUOK(ST(i + 1)))) {
0 4 if (SvOK(ST(i + 1)) && (SvIOK(ST(i + 1)) || SvUOK(ST(i + 1)))) {
0 0 if (SvOK(ST(i + 1)) && (SvIOK(ST(i + 1)) || SvUOK(ST(i + 1)))) {
1010 5522 4 size_t max_bin_size = (ignore == NULL) ? (hex_len / 2) : hex_len;
1014 0 5526 if (bin == NULL) {
1023 5526 0 if (status == 0) {
1024 4 5522 if (bin_max_len > 0 && bin_max_len < bin_len) {
2 2 if (bin_max_len > 0 && bin_max_len < bin_len) {
1036 5526 0 if (bin != NULL) sodium_free(bin);
1045 0 1 RETVAL = crypto_secretbox_NONCEBYTES;
1052 1 0 RETVAL = crypto_secretbox_KEYBYTES;
1059 1 5 RETVAL = crypto_secretbox_MACBYTES;
1092 0 5 if ( items > 2 ) {
1096 0 5 if (items == 2 ) {
1097 0 0 if ( SvOK(ST(1)) ) {
1101 0 0 if ( prev_nonce_len > crypto_secretbox_NONCEBYTES ) {
1143 0 10 if ( GIMME_V == G_VOID ) {
1148 0 10 if ( nonce_len != crypto_secretbox_NONCEBYTES ) {
1153 0 10 if ( key_len != crypto_secretbox_KEYBYTES ) {
1160 5 5 if ( GIMME_V == G_ARRAY ) {
1168 0 5 mXPUSHs( DataBytesLocker2SV(aTHX_ bl_mac) );
1169 0 5 mXPUSHs( DataBytesLocker2SV(aTHX_ bl) );
1178 0 5 mXPUSHs( DataBytesLocker2SV(aTHX_ bl) );
1203 0 5 if ( GIMME_V == G_VOID ) {
1208 0 5 if ( nonce_len != crypto_secretbox_NONCEBYTES ) {
1213 0 5 if ( key_len != crypto_secretbox_KEYBYTES ) {
1218 0 5 if ( msg_len < crypto_secretbox_MACBYTES ) {
1224 5 0 if ( crypto_secretbox_open_easy( bl->bytes, msg_buf, msg_len, nonce_buf, key_buf) == 0 ) {
1225 0 5 mXPUSHs( DataBytesLocker2SV(aTHX_ bl) );
1259 0 3 if ( GIMME_V == G_VOID ) {
1264 0 3 if ( nonce_len != crypto_secretbox_NONCEBYTES ) {
1269 0 3 if ( key_len != crypto_secretbox_KEYBYTES ) {
1274 0 3 if ( mac_len != crypto_secretbox_MACBYTES ) {
1281 3 0 if ( crypto_secretbox_open_detached( bl->bytes, msg_buf, mac_buf, msg_len, nonce_buf, key_buf) == 0 ) {
1282 0 3 mXPUSHs( DataBytesLocker2SV(aTHX_ bl) );
1403 0 20013 if ( GIMME_V == G_VOID ) {
1430 0 20013 if ( key_len != key_size ) {
1462 0 30002 if ( GIMME_V == G_VOID ) {
1467 0 30002 if ( mac_len != crypto_auth_BYTES ) {
1472 0 30002 if ( key_len != crypto_auth_KEYBYTES ) {
1478 10004 19998 if ( crypto_auth_verify( mac_buf, msg_buf, msg_len, key_buf) == 0 ) {
1513 0 30593 if ( GIMME_V == G_VOID ) {
1535 0 30593 if ( mac_len != mac_size ) {
1543 582 30011 if ( key_len != key_size ) {
1545 0 582 if ( expected == NULL ) {
1577 582 0 ? &PL_sv_yes : &PL_sv_no;
1580 10013 19998 ? &PL_sv_yes : &PL_sv_no;
1586 582 30011 if ( free_expected ) {
1607 0 197 if ( stream->state == NULL ) {
1635 0 197 if ( stream->state == NULL ) {
1664 0 199 if ( stream->state == NULL ) {
1686 0 0 CLONESTATE(CryptNaClSodiumAuthHmacsha256Stream, auth_hmacsha256, 0, ((void)0))
0 0 CLONESTATE(CryptNaClSodiumAuthHmacsha256Stream, auth_hmacsha256, 0, ((void)0))
1703 249 249 for ( i = 1; i < items ; i++ ) {
1754 0 0 CLONESTATE(CryptNaClSodiumAuthHmacsha512Stream, auth_hmacsha512, 0, ((void)0))
0 0 CLONESTATE(CryptNaClSodiumAuthHmacsha512Stream, auth_hmacsha512, 0, ((void)0))
1771 249 249 for ( i = 1; i < items ; i++ ) {
1823 0 0 CLONESTATE(CryptNaClSodiumAuthHmacsha512256Stream, auth_hmacsha512256, 0, ((void)0))
0 0 CLONESTATE(CryptNaClSodiumAuthHmacsha512256Stream, auth_hmacsha512256, 0, ((void)0))
1840 277 277 for ( i = 1; i < items ; i++ ) {
1888 0 3 RETVAL = crypto_aead_chacha20poly1305_KEYBYTES;
1896 382 2 RETVAL = crypto_aead_aes256gcm_KEYBYTES;
1907 382 2 RETVAL = crypto_aead_aes256gcm_NPUBBYTES;
1918 1756 5 RETVAL = crypto_aead_aes256gcm_ABYTES;
1928 1 1 RETVAL = crypto_aead_chacha20poly1305_NPUBBYTES;
1935 0 1 RETVAL = crypto_aead_chacha20poly1305_IETF_NPUBBYTES;
1942 1 6 RETVAL = crypto_aead_chacha20poly1305_ABYTES;
1953 1 0 if ( crypto_aead_aes256gcm_is_available() ) {
1971 0 3 switch(ix) {
2017 0 4 if ( items > 2 ) {
2021 0 4 if (items == 2 ) {
2022 0 0 if ( SvOK(ST(1)) ) {
2026 0 0 if ( prev_nonce_len > nonce_size ) {
2077 0 391 if ( GIMME_V == G_VOID ) {
2106 0 391 if ( nonce_len != nonce_size ) {
2111 0 391 if ( key_len != key_size ) {
2119 0 391 if (msg_len > SIZE_MAX - adlen_size) {
2130 0 391 mXPUSHs( DataBytesLocker2SV(aTHX_ bl) );
2165 0 1236 if ( GIMME_V == G_VOID ) {
2194 0 1236 if ( nonce_len != nonce_size ) {
2199 0 1236 if ( key_len != key_size ) {
2205 383 853 if ( msg_len < adlen_size ) {
2214 391 462 if ( (*decrypt_function)( bl->bytes, NULL, NULL, msg_buf, msg_len, adata_buf, adata_len, nonce_buf, key_buf) == 0 ) {
2217 0 391 mXPUSHs( DataBytesLocker2SV(aTHX_ bl) );
2243 0 384 if ( key_len != crypto_aead_aes256gcm_KEYBYTES ) {
2282 0 385 if ( GIMME_V == G_VOID ) {
2287 0 385 if ( nonce_len != crypto_aead_aes256gcm_NPUBBYTES ) {
2293 1 384 if ( precal_key->locked ) {
2301 0 384 if (msg_len > SIZE_MAX - crypto_aead_aes256gcm_ABYTES) {
2312 0 384 mXPUSHs( DataBytesLocker2SV(aTHX_ bl) );
2345 0 386 if ( GIMME_V == G_VOID ) {
2350 0 386 if ( nonce_len != crypto_aead_aes256gcm_NPUBBYTES ) {
2356 0 386 if ( msg_len < crypto_aead_aes256gcm_ABYTES ) {
2362 1 385 if ( precal_key->locked ) {
2371 385 0 if ( crypto_aead_aes256gcm_decrypt_afternm( bl->bytes, NULL, NULL, msg_buf, msg_len, adata_buf, adata_len, nonce_buf, (const crypto_aead_aes256gcm_state *) precal_key->ctx) == 0 ) {
2374 0 385 mXPUSHs( DataBytesLocker2SV(aTHX_ bl) );
2402 1 0 if (rc == 0 ) {
2426 1 0 if (rc == 0 ) {
2445 1 2 if ( state->locked ) {
2478 0 1 RETVAL = crypto_box_PUBLICKEYBYTES;
2485 1 0 RETVAL = crypto_box_SECRETKEYBYTES;
2492 1 0 RETVAL = crypto_box_NONCEBYTES;
2499 1 5 RETVAL = crypto_box_MACBYTES;
2506 1 0 RETVAL = crypto_box_SEEDBYTES;
2513 1 0 RETVAL = crypto_box_BEFORENMBYTES;
2530 0 12 if ( items > 2 ) {
2534 4 8 else if ( items == 2 ) {
2535 4 0 if ( SvPOK(ST(1)) || (SvROK(ST(1)) && sv_derived_from(ST(1), "Data::BytesLocker"))) {
4 0 if ( SvPOK(ST(1)) || (SvROK(ST(1)) && sv_derived_from(ST(1), "Data::BytesLocker"))) {
4 0 if ( SvPOK(ST(1)) || (SvROK(ST(1)) && sv_derived_from(ST(1), "Data::BytesLocker"))) {
2539 0 4 if ( seed_len != crypto_box_SEEDBYTES ) {
2557 0 12 mXPUSHs( DataBytesLocker2SV(aTHX_ blp) );
2558 0 12 mXPUSHs( DataBytesLocker2SV(aTHX_ bls) );
2575 0 4 if ( skey_len != crypto_box_SECRETKEYBYTES ) {
2623 0 8 if ( pkey_len != crypto_box_PUBLICKEYBYTES ) {
2628 0 8 if ( skey_len != crypto_box_SECRETKEYBYTES ) {
2634 0 8 if ( crypto_box_beforenm(bl->bytes, pkey_buf, skey_buf) != 0 ) {
2654 0 5 if ( items > 2 ) {
2658 0 5 if (items == 2 ) {
2659 0 0 if ( SvOK(ST(1)) ) {
2663 0 0 if ( prev_nonce_len > crypto_box_NONCEBYTES ) {
2708 0 8 if ( GIMME_V == G_VOID ) {
2713 0 8 if ( nonce_len != crypto_box_NONCEBYTES ) {
2718 0 8 if ( pkey_len != crypto_box_PUBLICKEYBYTES ) {
2723 0 8 if ( skey_len != crypto_box_SECRETKEYBYTES ) {
2730 3 5 if ( GIMME_V == G_ARRAY ) {
2736 0 3 if ( crypto_box_detached( bl->bytes, blm->bytes, (unsigned char *)msg_buf,
2746 0 3 mXPUSHs( DataBytesLocker2SV(aTHX_ blm) );
2747 0 3 mXPUSHs( DataBytesLocker2SV(aTHX_ bl) );
2755 0 5 if ( crypto_box_easy( bl->bytes, msg_buf, msg_len, nonce_buf, pkey_buf, skey_buf) != 0 ) {
2761 0 5 mXPUSHs( DataBytesLocker2SV(aTHX_ bl) );
2787 0 7 if ( GIMME_V == G_VOID ) {
2792 0 7 if ( nonce_len != crypto_box_NONCEBYTES ) {
2797 0 7 if ( key_len != crypto_box_BEFORENMBYTES ) {
2804 4 3 if ( GIMME_V == G_ARRAY ) {
2812 0 4 mXPUSHs( DataBytesLocker2SV(aTHX_ blm) );
2813 0 4 mXPUSHs( DataBytesLocker2SV(aTHX_ bl) );
2824 0 3 mXPUSHs( DataBytesLocker2SV(aTHX_ bl) );
2853 0 5 if ( GIMME_V == G_VOID ) {
2858 0 5 if ( nonce_len != crypto_box_NONCEBYTES ) {
2863 0 5 if ( pkey_len != crypto_box_PUBLICKEYBYTES ) {
2868 0 5 if ( skey_len != crypto_box_SECRETKEYBYTES ) {
2874 0 5 if ( msg_len < crypto_box_MACBYTES ) {
2881 5 0 if ( crypto_box_open_easy( bl->bytes, msg_buf, msg_len, nonce_buf, pkey_buf, skey_buf) == 0 ) {
2919 0 2 if ( GIMME_V == G_VOID ) {
2924 0 2 if ( nonce_len != crypto_box_NONCEBYTES ) {
2929 0 2 if ( pkey_len != crypto_box_PUBLICKEYBYTES ) {
2934 0 2 if ( skey_len != crypto_box_SECRETKEYBYTES ) {
2939 0 2 if ( mac_len != crypto_box_MACBYTES ) {
2946 2 0 if ( crypto_box_open_detached( bl->bytes, msg_buf, mac_buf, msg_len, nonce_buf, pkey_buf, skey_buf) == 0 ) {
2979 0 4 if ( GIMME_V == G_VOID ) {
2984 0 4 if ( nonce_len != crypto_box_NONCEBYTES ) {
2989 0 4 if ( key_len != crypto_box_BEFORENMBYTES ) {
2995 0 4 if ( msg_len < crypto_box_MACBYTES ) {
3002 4 0 if ( crypto_box_open_easy_afternm( bl->bytes, msg_buf, msg_len, nonce_buf, key_buf) == 0 ) {
3037 0 3 if ( GIMME_V == G_VOID ) {
3042 0 3 if ( nonce_len != crypto_box_NONCEBYTES ) {
3047 0 3 if ( key_len != crypto_box_BEFORENMBYTES ) {
3052 0 3 if ( mac_len != crypto_box_MACBYTES ) {
3059 3 0 if ( crypto_box_open_detached_afternm( bl->bytes, msg_buf, mac_buf, msg_len, nonce_buf, key_buf) == 0 ) {
3079 1024 1 RETVAL = crypto_sign_PUBLICKEYBYTES;
3086 1 0 RETVAL = crypto_sign_SECRETKEYBYTES;
3093 1023 2 RETVAL = crypto_sign_BYTES;
3100 1024 1 RETVAL = crypto_sign_SEEDBYTES;
3117 0 511 if ( items > 2 ) {
3121 6 505 else if ( items == 2 ) {
3122 4 2 if ( SvPOK(ST(1)) || (SvROK(ST(1)) && sv_derived_from(ST(1), "Data::BytesLocker"))) {
4 0 if ( SvPOK(ST(1)) || (SvROK(ST(1)) && sv_derived_from(ST(1), "Data::BytesLocker"))) {
4 0 if ( SvPOK(ST(1)) || (SvROK(ST(1)) && sv_derived_from(ST(1), "Data::BytesLocker"))) {
3126 0 6 if ( seed_len != crypto_sign_SEEDBYTES ) {
3144 0 511 mXPUSHs( DataBytesLocker2SV(aTHX_ blp) );
3145 0 511 mXPUSHs( DataBytesLocker2SV(aTHX_ bls) );
3168 0 501 if ( pkey_len != crypto_sign_ed25519_PUBLICKEYBYTES ) {
3173 0 501 if ( skey_len != crypto_sign_ed25519_SECRETKEYBYTES ) {
3179 0 501 if ( crypto_sign_ed25519_pk_to_curve25519( blp->bytes, pkey_buf) != 0 ) {
3186 0 501 if ( crypto_sign_ed25519_sk_to_curve25519( bls->bytes, skey_buf) != 0 ) {
3192 0 501 mXPUSHs( DataBytesLocker2SV(aTHX_ blp) );
3193 0 501 mXPUSHs( DataBytesLocker2SV(aTHX_ bls) );
3211 0 5 if ( skey_len != crypto_sign_SECRETKEYBYTES ) {
3216 0 5 mXPUSHs( DataBytesLocker2SV(aTHX_ bl) );
3233 0 5 if ( skey_len != crypto_sign_SECRETKEYBYTES ) {
3238 0 5 mXPUSHs( DataBytesLocker2SV(aTHX_ bl) );
3253 0 2 mXPUSHs( DataBytesLocker2SV(aTHX_ bl) );
3274 0 1027 if ( GIMME_V == G_VOID ) {
3279 0 1027 if ( skey_len != crypto_sign_SECRETKEYBYTES ) {
3285 0 1027 if (msg_len > SIZE_MAX - crypto_sign_BYTES) {
3294 0 1027 mXPUSHs( DataBytesLocker2SV(aTHX_ bl) );
3315 0 3 if ( GIMME_V == G_VOID ) {
3320 0 3 if ( skey_len != crypto_sign_SECRETKEYBYTES ) {
3330 0 3 mXPUSHs( DataBytesLocker2SV(aTHX_ bl) );
3352 0 3 if ( GIMME_V == G_VOID ) {
3357 0 3 if ( sig_len != crypto_sign_BYTES ) {
3362 0 3 if ( pkey_len != crypto_sign_PUBLICKEYBYTES ) {
3368 3 0 if ( crypto_sign_verify_detached( sig_buf, msg_buf, msg_len, pkey_buf) == 0 ) {
3394 0 2051 if ( GIMME_V == G_VOID ) {
3399 0 2051 if ( pkey_len != crypto_sign_PUBLICKEYBYTES ) {
3405 0 2051 if ( msg_len < crypto_sign_BYTES ) {
3412 1027 1024 if ( crypto_sign_open( bl->bytes, NULL, msg_buf, msg_len, pkey_buf) == 0 ) {
3416 0 1027 mXPUSHs( DataBytesLocker2SV(aTHX_ bl) );
3434 0 2 RETVAL = crypto_generichash_BYTES;
3441 2 185 RETVAL = crypto_generichash_BYTES_MIN;
3448 2 187 RETVAL = crypto_generichash_BYTES_MAX;
3455 2 1 RETVAL = crypto_generichash_KEYBYTES;
3462 2 13 RETVAL = crypto_generichash_KEYBYTES_MIN;
3469 2 16 RETVAL = crypto_generichash_KEYBYTES_MAX;
3485 169 0 if ( keybytes < crypto_generichash_KEYBYTES_MIN || keybytes > crypto_generichash_KEYBYTES_MAX ) {
0 169 if ( keybytes < crypto_generichash_KEYBYTES_MIN || keybytes > crypto_generichash_KEYBYTES_MAX ) {
3514 2419 0 if ( items > 2 && ( items > 6 || items % 2 != 0 ) ) {
2419 0 if ( items > 2 && ( items > 6 || items % 2 != 0 ) ) {
0 2419 if ( items > 2 && ( items > 6 || items % 2 != 0 ) ) {
3516 2419 0 } else if ( items > 2 ) {
3521 4668 2417 for ( i = 2; i < items; i += 2 ) {
3523 2249 2419 if ( keylen == 3 && strnEQ(key, "key", 3) ) {
2249 0 if ( keylen == 3 && strnEQ(key, "key", 3) ) {
3525 2249 0 if ( key_len < crypto_generichash_KEYBYTES_MIN || key_len > crypto_generichash_KEYBYTES_MAX ) {
0 2249 if ( key_len < crypto_generichash_KEYBYTES_MIN || key_len > crypto_generichash_KEYBYTES_MAX ) {
3529 2419 0 else if ( keylen == 5 && strnEQ(key, "bytes", 5) ) {
2419 0 else if ( keylen == 5 && strnEQ(key, "bytes", 5) ) {
3531 2418 1 if ( bytes < crypto_generichash_BYTES_MIN || bytes > crypto_generichash_BYTES_MAX ) {
1 2417 if ( bytes < crypto_generichash_BYTES_MIN || bytes > crypto_generichash_BYTES_MAX ) {
3564 4786 0 if ( items > 1 && ( items > 5 || (items + 1) % 2 != 0 ) ) {
4786 0 if ( items > 1 && ( items > 5 || (items + 1) % 2 != 0 ) ) {
0 4786 if ( items > 1 && ( items > 5 || (items + 1) % 2 != 0 ) ) {
3566 4786 0 } else if ( items > 1 ) {
3571 9230 4783 for ( i = 1; i < items; i += 2 ) {
3573 4445 4785 if ( keylen == 3 && strnEQ(key, "key", 3) ) {
4445 0 if ( keylen == 3 && strnEQ(key, "key", 3) ) {
3575 4445 0 if ( key_len < crypto_generichash_KEYBYTES_MIN || key_len > crypto_generichash_KEYBYTES_MAX ) {
1 4444 if ( key_len < crypto_generichash_KEYBYTES_MIN || key_len > crypto_generichash_KEYBYTES_MAX ) {
3579 4785 0 else if ( keylen == 5 && strnEQ(key, "bytes", 5) ) {
4785 0 else if ( keylen == 5 && strnEQ(key, "bytes", 5) ) {
3581 4784 1 if ( bytes < crypto_generichash_BYTES_MIN || bytes > crypto_generichash_BYTES_MAX ) {
1 4783 if ( bytes < crypto_generichash_BYTES_MIN || bytes > crypto_generichash_BYTES_MAX ) {
3592 0 4783 if ( stream->state == NULL ) {
3615 0 0 CLONESTATE(CryptNaClSodiumGenerichashStream, generichash, (size_t)63U & ~(size_t) 63U, new_stream->init_bytes=cur_stream->init_bytes)
0 0 CLONESTATE(CryptNaClSodiumGenerichashStream, generichash, (size_t)63U & ~(size_t) 63U, new_stream->init_bytes=cur_stream->init_bytes)
3632 123502 123502 for ( i = 1; i < items ; i++ ) {
3654 4732 50 if ( items > 1 && items != 3 ) {
0 4732 if ( items > 1 && items != 3 ) {
3656 4732 50 } else if ( items > 1 ) {
3661 4732 4732 for ( i = 1; i < items; i += 2 ) {
3663 4732 0 if ( keylen == 5 && strnEQ(key, "bytes", 5) ) {
4732 0 if ( keylen == 5 && strnEQ(key, "bytes", 5) ) {
3665 4732 0 if ( bytes < crypto_generichash_BYTES_MIN || bytes > crypto_generichash_BYTES_MAX ) {
0 4732 if ( bytes < crypto_generichash_BYTES_MIN || bytes > crypto_generichash_BYTES_MAX ) {
3677 0 4782 mXPUSHs( DataBytesLocker2SV(aTHX_ bl) );
3700 0 2 RETVAL = crypto_shorthash_BYTES;
3707 2 2 RETVAL = crypto_shorthash_KEYBYTES;
3750 0 67 if ( key_len != crypto_shorthash_KEYBYTES ) {
3772 0 2 RETVAL = crypto_pwhash_scryptsalsa208sha256_SALTBYTES;
3779 18 2 RETVAL = crypto_pwhash_scryptsalsa208sha256_STRBYTES;
3786 2 3 RETVAL = crypto_pwhash_scryptsalsa208sha256_OPSLIMIT_INTERACTIVE;
3793 6 7 RETVAL = crypto_pwhash_scryptsalsa208sha256_MEMLIMIT_INTERACTIVE;
3800 1 0 RETVAL = crypto_pwhash_scryptsalsa208sha256_OPSLIMIT_SENSITIVE;
3807 1 0 RETVAL = crypto_pwhash_scryptsalsa208sha256_MEMLIMIT_SENSITIVE;
3851 19 0 if ( items > 3 && ( ( items + 1 ) % 2 != 0 || items > 9 ) ) {
19 0 if ( items > 3 && ( ( items + 1 ) % 2 != 0 || items > 9 ) ) {
0 19 if ( items > 3 && ( ( items + 1 ) % 2 != 0 || items > 9 ) ) {
3853 19 0 } else if ( items > 4 ) {
3858 43 19 for ( i = 3; i < items; i += 2 ) {
3860 24 19 if ( keylen == 8 && strnEQ(key, "opslimit", 8) ) {
12 12 if ( keylen == 8 && strnEQ(key, "opslimit", 8) ) {
3862 0 12 if ( opslimit < 1 ) {
3865 12 19 } else if ( keylen == 8 && strnEQ(key, "memlimit", 8) ) {
12 0 } else if ( keylen == 8 && strnEQ(key, "memlimit", 8) ) {
3867 0 12 if ( memlimit < 1 ) {
3870 19 0 } else if ( keylen == 5 && strnEQ(key, "bytes", 5) ) {
19 0 } else if ( keylen == 5 && strnEQ(key, "bytes", 5) ) {
3872 0 19 if ( outlen < 1 ) {
3882 0 19 if ( salt_len != crypto_pwhash_scryptsalsa208sha256_SALTBYTES ) {
3889 0 19 if ( crypto_pwhash_scryptsalsa208sha256(bl->bytes, outlen, pwd_buf, pwd_len, salt_buf, opslimit, memlimit) != 0 ) {
3895 0 19 mXPUSHs( DataBytesLocker2SV(aTHX_ bl) );
3916 20 1 if ( items > 2 && ( items % 2 != 0 || items > 6 ) ) {
20 0 if ( items > 2 && ( items % 2 != 0 || items > 6 ) ) {
0 20 if ( items > 2 && ( items % 2 != 0 || items > 6 ) ) {
3918 20 1 } else if ( items > 2 ) {
3923 40 20 for ( i = 2; i < items; i += 2 ) {
3925 40 0 if ( keylen == 8 && strnEQ(key, "opslimit", 8) ) {
20 20 if ( keylen == 8 && strnEQ(key, "opslimit", 8) ) {
3927 0 20 if ( opslimit < 1 ) {
3930 20 0 } else if ( keylen == 8 && strnEQ(key, "memlimit", 8) ) {
20 0 } else if ( keylen == 8 && strnEQ(key, "memlimit", 8) ) {
3932 0 20 if ( memlimit < 1 ) {
3944 0 21 if ( crypto_pwhash_scryptsalsa208sha256_str((char *)bl->bytes, pwd_buf, pwd_len, opslimit, memlimit) != 0 ) {
3951 0 21 mXPUSHs( DataBytesLocker2SV(aTHX_ bl) );
3975 23 26 if ( str_len == crypto_pwhash_scryptsalsa208sha256_STRBYTES - 1 ) {
3981 0 23 if ( str102 == NULL ) {
3993 21 5 else if ( str_len == crypto_pwhash_scryptsalsa208sha256_STRBYTES
3995 21 0 str_buf[crypto_pwhash_scryptsalsa208sha256_STRBYTES - 1] == 0
4005 30 14 RETVAL = res ? &PL_sv_yes : &PL_sv_no;
4018 0 2 RETVAL = crypto_hash_sha256_BYTES;
4025 2 0 RETVAL = crypto_hash_sha512_BYTES;
4048 6 10 switch(ix) {
4058 0 16 mXPUSHs( DataBytesLocker2SV(aTHX_ bl) );
4074 0 4 if ( stream->state == NULL ) {
4097 0 4 if ( stream->state == NULL ) {
4120 0 0 CLONESTATE(CryptNaClSodiumHashSha256Stream, hash_sha256, 0, ((void)0))
0 0 CLONESTATE(CryptNaClSodiumHashSha256Stream, hash_sha256, 0, ((void)0))
4136 357 357 for ( i = 1; i < items ; i++ ) {
4159 0 4 mXPUSHs( DataBytesLocker2SV(aTHX_ bl) );
4186 0 0 CLONESTATE(CryptNaClSodiumHashSha512Stream, hash_sha512, 0, ((void)0))
0 0 CLONESTATE(CryptNaClSodiumHashSha512Stream, hash_sha512, 0, ((void)0))
4202 357 357 for ( i = 1; i < items ; i++ ) {
4225 0 4 mXPUSHs( DataBytesLocker2SV(aTHX_ bl) );
4249 9998 1 RETVAL = crypto_onetimeauth_BYTES;
4256 0 1 RETVAL = crypto_onetimeauth_KEYBYTES;
4298 0 10003 if ( key_len != crypto_onetimeauth_KEYBYTES ) {
4307 0 10003 mXPUSHs( DataBytesLocker2SV(aTHX_ bl) );
4329 0 30004 if ( GIMME_V == G_VOID ) {
4334 0 30004 if ( mac_len != crypto_onetimeauth_BYTES ) {
4339 0 30004 if ( key_len != crypto_onetimeauth_KEYBYTES ) {
4345 10006 19998 if ( crypto_onetimeauth_verify( mac_buf, msg_buf, msg_len, key_buf) == 0 ) {
4368 0 3 if ( key_len != crypto_onetimeauth_KEYBYTES ) {
4374 0 3 if ( stream->state == NULL ) {
4397 0 0 CLONESTATE(CryptNaClSodiumOnetimeauthStream, onetimeauth, 0, ((void)0))
0 0 CLONESTATE(CryptNaClSodiumOnetimeauthStream, onetimeauth, 0, ((void)0))
4414 26 26 for ( i = 1; i < items ; i++ ) {
4437 0 3 mXPUSHs( DataBytesLocker2SV(aTHX_ bl) );
4460 0 1 RETVAL = crypto_scalarmult_BYTES;
4468 1 0 RETVAL = crypto_scalarmult_SCALARBYTES;
4505 0 508 if ( GIMME_V == G_VOID ) {
4510 0 508 if ( key_len != crypto_scalarmult_SCALARBYTES ) {
4517 0 508 mXPUSHs( DataBytesLocker2SV(aTHX_ bl) );
4539 0 7 if ( GIMME_V == G_VOID ) {
4544 0 7 if ( skey_len != crypto_scalarmult_SCALARBYTES ) {
4549 0 7 if ( pkey_len != crypto_scalarmult_SCALARBYTES ) {
4555 0 7 if ( crypto_scalarmult( bl->bytes, skey_buf, pkey_buf) != 0 ) {
4561 0 7 mXPUSHs( DataBytesLocker2SV(aTHX_ bl) );
4573 1 2 RETVAL = crypto_stream_NONCEBYTES;
4580 2 1 RETVAL = crypto_stream_KEYBYTES;
4587 1 2 RETVAL = crypto_stream_chacha20_NONCEBYTES;
4594 0 0 RETVAL = crypto_stream_chacha20_IETF_NONCEBYTES;
4601 1 2 RETVAL = crypto_stream_chacha20_KEYBYTES;
4608 2 1 RETVAL = crypto_stream_salsa20_NONCEBYTES;
4615 2 1 RETVAL = crypto_stream_salsa20_KEYBYTES;
4717 0 3 if ( items > 2 ) {
4721 0 3 if (items == 2 ) {
4722 0 0 if ( SvOK(ST(1)) ) {
4726 0 0 if ( prev_nonce_len > nonce_size ) {
4774 0 16 if ( GIMME_V == G_VOID ) {
4826 0 16 if ( nonce_len != nonce_size ) {
4831 0 16 if ( key_len != key_size ) {
4839 0 16 mXPUSHs( DataBytesLocker2SV(aTHX_ bl) );
4872 0 19 if ( GIMME_V == G_VOID ) {
4922 0 19 if ( nonce_len != nonce_size ) {
4927 0 19 if ( key_len != key_size ) {
4937 0 19 mXPUSHs( DataBytesLocker2SV(aTHX_ bl) );
4968 0 13 if ( GIMME_V == G_VOID ) {
4992 0 13 if ( nonce_len != nonce_size ) {
4997 0 13 if ( key_len != key_size ) {
5007 0 13 mXPUSHs( DataBytesLocker2SV(aTHX_ bl) );
5031 0 9 if ( GIMME_V == G_VOID ) {
5038 0 9 if ( nonce_len != crypto_stream_chacha20_IETF_NONCEBYTES ) {
5043 0 9 if ( key_len != crypto_stream_chacha20_KEYBYTES ) {
5053 0 9 mXPUSHs( DataBytesLocker2SV(aTHX_ bl) );
5074 6 1009 if ( SvREADONLY(bytes) ) {
5081 3 1012 if ( items > 2 && items != 4 ) {
0 3 if ( items > 2 && items != 4 ) {
5083 3 1012 } else if ( items > 2 ) {
5088 3 2 for ( i = 2; i < items; i += 2 ) {
5090 3 0 if ( keylen == 4 && strnEQ(key, "wipe", 4) ) {
3 0 if ( keylen == 4 && strnEQ(key, "wipe", 4) ) {
5092 3 0 if ( wipe && readonly ) {
1 2 if ( wipe && readonly ) {
5104 2 1012 if ( wipe ) {
5127 0 8 if ( sbl->locked ) {
5135 40 8 while(count--) {
5159 0 7 if ( sbl->locked ) {
5167 2 5 if ( SvTRUE(swapped) ) {
5190 0 6766 if ( sbl->locked ) {
5194 6766 0 if ( sbl->length ) {
5200 6766 0 if ( res ) {
5218 0 0 if ( sbl->locked ) {
5222 0 0 if ( sbl->length ) {
5228 0 0 if ( res ) {
5249 0 1589 if ( sbl->locked ) {
5255 0 1589 if ( sbl->length != buf_len ) {
5259 1589 0 if ( sodium_memcmp(sbl->bytes, buf, sbl->length) == 0 ) {
5265 1589 0 if ( res ) {
5287 0 1026 if ( sbl->locked ) {
5293 0 1026 if ( sbl->length != buf_len ) {
5297 2 1024 if ( sodium_memcmp(sbl->bytes, buf, sbl->length) == 0 ) {
5303 1024 2 if ( res ) {
5320 13 300254 if ( sbl->locked ) {
5327 0 300254 mXPUSHs(pv);
5351 0 1 if ( sbl->locked ) {
5375 4 0 if (rc == 0 ) {
5394 13 0 if (rc == 0 ) {
5409 0 690 if ( sbl->locked ) {
5425 4 3 if ( sbl->locked ) {
5442 0 6304 if ( sbl->locked ) {
5448 0 6304 if ( hex == NULL ) {
5469 1 3463 if ( sbl->locked ) {
5475 0 3463 mXPUSHs(pv);
5490 0 1005 if ( GIMME_V == G_VOID ) {
5494 0 1005 if ( sbl->locked ) {
5498 0 1005 if (sv_derived_from(bytes, "Data::BytesLocker")) {
5500 0 0 if ( rbl->locked ) {
5510 2 1003 if ( length == 0 ) {
5511 1 1 if ( sbl->length != bytes_len ) {
5516 1 1002 if ( length > sbl->length ) {
5519 1 1001 else if ( length > bytes_len ) {
5524 1 1001 if ( sodium_memcmp(sbl->bytes, bytes_buf, length) == 0 ) {
5544 0 2005 if ( GIMME_V == G_VOID ) {
5548 0 2005 if ( sbl->locked ) {
5552 1001 1004 if (sv_derived_from(num, "Data::BytesLocker")) {
5554 0 1001 if ( rbl->locked ) {
5564 2 2003 if ( length == 0 ) {
5565 1 1 if ( sbl->length != num_len ) {
5570 1 2002 if ( length > sbl->length ) {
5573 1 2001 else if ( length > num_len ) {
5591 0 4817 if ( GIMME_V == G_VOID ) {
5595 0 4817 if ( sbl->locked ) {
5605 0 4817 mXPUSHs( DataBytesLocker2SV(aTHX_ bl) );
5623 0 7 if ( GIMME_V == G_VOID ) {
5627 0 7 if ( sbl->locked ) {
5631 7 0 if (sv_derived_from(num, "Data::BytesLocker")) {
5633 0 7 if ( rbl->locked ) {
5643 6 1 if ( items == 3 ) {
5645 0 6 if ( inc_len > sbl->length ) {
5648 0 6 else if ( inc_len > num_len ) {
5652 0 1 if ( sbl->length != num_len ) {
5664 0 7 mXPUSHs( DataBytesLocker2SV(aTHX_ bl) );
5678 0 2 if ( sbl->locked ) {
5682 1 1 if ( sodium_is_zero(sbl->bytes, sbl->length) == 1 ) {