| 1 |
|
| MODULE = Crypt::JWS PACKAGE = Crypt::JWS |
| 2 |
|
| |
| 3 |
|
| SV * |
| 4 |
|
| sha256(bytes) |
| 5 |
|
| SV *bytes |
| 6 |
|
| ALIAS: |
| 7 |
|
| sha384 = 384 |
| 8 |
|
| sha512 = 512 |
| 9 |
|
| sha1 = 160 |
| 10 |
|
| CODE: |
| 11 |
|
| STRLEN len; |
| 12 |
6 |
| const char *p = SvPVbyte(bytes, len); |
| 13 |
6 |
▶ | int bits = ix ? (int)ix : 256; |
Branch: 1 branch
| Branch | True | False | Total |
| int bits = ix ? (int)ix : 256; |
5 |
1 |
6 |
|
| 14 |
|
| unsigned char out[EVP_MAX_MD_SIZE]; |
| 15 |
6 |
| unsigned n = cjws_digest(bits, (const unsigned char *)p, len, out); |
| 16 |
6 |
▶ | if (!n) |
Branch: 1 branch
| Branch | True | False | Total |
| if (!n) |
0 |
6 |
6 |
|
| 17 |
0 |
| croak("Crypt::JWS: digest failed"); |
| 18 |
6 |
| RETVAL = newSVpvn((const char *)out, n); |
| 19 |
|
| OUTPUT: |
| 20 |
|
| RETVAL |
| 21 |
|
| |
| 22 |
|
| SV * |
| 23 |
|
| hmac_sha256(key, bytes) |
| 24 |
|
| SV *key |
| 25 |
|
| SV *bytes |
| 26 |
|
| ALIAS: |
| 27 |
|
| hmac_sha384 = 384 |
| 28 |
|
| hmac_sha512 = 512 |
| 29 |
|
| hmac_sha1 = 160 |
| 30 |
|
| CODE: |
| 31 |
|
| STRLEN klen, len; |
| 32 |
12 |
▶ | const char *kp = SvPVbyte(key, klen); |
Branch: 1 branch
| Branch | True | False | Total |
| const char *kp = SvPVbyte(key, klen); |
12 |
0 |
12 |
|
| 33 |
12 |
| const char *p = SvPVbyte(bytes, len); |
| 34 |
12 |
▶ | int bits = ix ? (int)ix : 256; |
Branch: 1 branch
| Branch | True | False | Total |
| int bits = ix ? (int)ix : 256; |
10 |
2 |
12 |
|
| 35 |
|
| unsigned char out[EVP_MAX_MD_SIZE]; |
| 36 |
12 |
| STRLEN n = cjws_hmac(bits, (const unsigned char *)kp, klen, |
| 37 |
|
| (const unsigned char *)p, len, out); |
| 38 |
12 |
▶ | if (!n) |
Branch: 1 branch
| Branch | True | False | Total |
| if (!n) |
0 |
12 |
12 |
|
| 39 |
0 |
| croak("Crypt::JWS: hmac failed"); |
| 40 |
12 |
| RETVAL = newSVpvn((const char *)out, n); |
| 41 |
|
| OUTPUT: |
| 42 |
|
| RETVAL |