xs/password.xs

filter: Statementstmt 91.1% 41 / 45 Branchbran 61.7% 43 / 68 (1 uncoverable) Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 73.4% 84 / 113 (1 uncoverable) CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« xs/oamount.xs ↑ Summary include/punk/pk_abi_impl.h »
1 MODULE = Punk PACKAGE = Punk::Auth::Password
2  
3 PROTOTYPES: DISABLE
4  
5 # Password hashing (punk_password.h): PBKDF2-HMAC-SHA256 over the dist's own
6 # SHA-256, in the MaatSite::Password stored format. Callable as functions or
7 # as class methods - a leading 'Punk::Auth::Password' invocant is skipped, so
8 # migrating code written against the class-method style keeps working.
9  
10 # The iteration default: an explicit argument wins, then the localizable
11 # our $ITERATIONS in Punk/Auth/Password.pm, then the built-in 60_000.
12 SV *
13 hash(...)
14 CODE:
15 {
16 25 int i = 0;
17 SV *plain;
18 25 U32 iterations = 0;
19 STRLEN pl;
20 const unsigned char *p;
21 25 ▶ # uncoverable branch true
Branch: 3 branches
BranchTrueFalseTotal
# uncoverable branch true 25 0 25
# uncoverable branch true 24 1 25
# uncoverable branch true 0 24 24
22 0 # uncoverable condition left count:1 class:ignore_covered_err
23 25 ▶ # uncoverable condition right count:1 class:ignore_covered_err
Branch: 2 branches
BranchTrueFalseTotal
# uncoverable condition right count:1 class:ignore_covered_err 25 0 25
# uncoverable condition right count:1 class:ignore_covered_err 1 24 25
24 1 # uncoverable condition left count:2 class:ignore_covered_err
25 24 # uncoverable condition left count:3 class:ignore_covered_err
26 24 ▶ if (items > i && SvPOK(ST(i)) && sv_derived_from(ST(i), "Punk::Auth::Password"))
Branch: 2 branches
BranchTrueFalseTotal
if (items > i && SvPOK(ST(i)) && sv_derived_from(ST(i), "Punk::Auth::Password")) 4 20 24
if (items > i && SvPOK(ST(i)) && sv_derived_from(ST(i), "Punk::Auth::Password")) 4 0 4
27 4 i++; /* # uncoverable statement */
28 4 ▶ if (items <= i || !SvOK(ST(i))) /* # uncoverable condition left count:1 class:ignore_covered_err */
Branch: 1 branch
BranchTrueFalseTotal
if (items <= i || !SvOK(ST(i))) /* # uncoverable condition left count:1 class:ignore_covered_err */ 1 3 4
29 1 croak("Punk::Auth::Password: hash needs a password");
30 3 plain = ST(i);
31 if (items > i + 1 && SvOK(ST(i + 1))) { /* # uncoverable condition right count:2 class:ignore_covered_err */
32 IV want = SvIV(ST(i + 1));
33 20 if (want <= 0)
34 20 ▶ croak("Punk::Auth::Password: iterations must be positive");
Branch: 3 branches
BranchTrueFalseTotal
croak("Punk::Auth::Password: iterations must be positive"); 20 0 20
croak("Punk::Auth::Password: iterations must be positive"); 20 0 20
croak("Punk::Auth::Password: iterations must be positive"); 20 0 20
35 20 iterations = (U32)want;
36 }
37 23 else {
38 23 SV *itsv = get_sv("Punk::Auth::Password::ITERATIONS", 0);
39 # uncoverable branch false
40 # uncoverable condition right count:1 class:ignore_covered_err
41 # uncoverable condition right count:2 class:ignore_covered_err
42 # uncoverable condition right count:3 class:ignore_covered_err
43 if (itsv && SvOK(itsv) && SvIV(itsv) > 0)
44 iterations = (U32)SvIV(itsv);
45 }
46 p = (const unsigned char *)SvPV(plain, pl);
47 RETVAL = pwd_hash(aTHX_ p, pl, iterations);
48 }
49 OUTPUT:
50 RETVAL
51  
52 IV
53 verify(...)
54 CODE:
55 {
56 15 int i = 0;
57 STRLEN pl, sl;
58 const unsigned char *p;
59 const char *s;
60 15 ▶ # uncoverable condition right count:1 class:ignore_covered_err
Branch: 3 branches
BranchTrueFalseTotal
# uncoverable condition right count:1 class:ignore_covered_err 15 0 15
# uncoverable condition right count:1 class:ignore_covered_err 15 0 15
# uncoverable condition right count:1 class:ignore_covered_err 1 14 15
61 1 # uncoverable condition right count:2 class:ignore_covered_err
62 15 ▶ if (items > i && SvPOK(ST(i)) && sv_derived_from(ST(i), "Punk::Auth::Password"))
Branch: 3 branches
BranchTrueFalseTotal
if (items > i && SvPOK(ST(i)) && sv_derived_from(ST(i), "Punk::Auth::Password")) 15 0 15
if (items > i && SvPOK(ST(i)) && sv_derived_from(ST(i), "Punk::Auth::Password")) 15 0 15
if (items > i && SvPOK(ST(i)) && sv_derived_from(ST(i), "Punk::Auth::Password")) 1 14 15
63 1 i++;
64 # uncoverable condition left count:1 class:ignore_covered_err
65 14 # uncoverable condition left count:2 class:ignore_covered_err
66 14 ▶ if (items <= i + 1 || !SvOK(ST(i)) || !SvOK(ST(i + 1)))
Branch: 1 branch
BranchTrueFalseTotal
if (items <= i + 1 || !SvOK(ST(i)) || !SvOK(ST(i + 1))) 14 0 14
67 14 RETVAL = 0;
68 else {
69 p = (const unsigned char *)SvPV(ST(i), pl);
70 s = SvPV(ST(i + 1), sl);
71 RETVAL = pwd_verify(aTHX_ p, pl, s, sl);
72 }
73 }
74 OUTPUT:
75 RETVAL
76  
77 IV
78 needs_rehash(...)
79 CODE:
80 {
81 7 int i = 0;
82 7 U32 current = 0;
83 STRLEN sl;
84 const char *s;
85 SV *itsv;
86 7 ▶ # uncoverable branch true
Branch: 3 branches
BranchTrueFalseTotal
# uncoverable branch true 7 0 7
# uncoverable branch true 6 1 7
# uncoverable branch true 0 6 6
87 0 # uncoverable condition left count:1 class:ignore_covered_err
88 7 # uncoverable condition right count:1 class:ignore_covered_err
89 7 ▶ # uncoverable condition left count:2 class:ignore_covered_err
Branch: 3 branches
BranchTrueFalseTotal
# uncoverable condition left count:2 class:ignore_covered_err 7 0 7
# uncoverable condition left count:2 class:ignore_covered_err 7 0 7
# uncoverable condition left count:2 class:ignore_covered_err 7 0 7
90 7 ▶ # uncoverable condition left count:3 class:ignore_covered_err
Branch: 3 branches
BranchTrueFalseTotal
# uncoverable condition left count:3 class:ignore_covered_err 1 6 7
# uncoverable condition left count:3 class:ignore_covered_err 1 0 1
# uncoverable condition left count:3 class:ignore_covered_err 1 0 1
91 1 if (items > i && SvPOK(ST(i)) && sv_derived_from(ST(i), "Punk::Auth::Password"))
92 7 ▶ i++; /* # uncoverable statement */
Branch: 2 branches
BranchTrueFalseTotal
i++; /* # uncoverable statement */ 7 0 7
i++; /* # uncoverable statement */ 1 6 7
93 1 itsv = get_sv("Punk::Auth::Password::ITERATIONS", 0);
94 # uncoverable branch false
95 6 # uncoverable condition right count:1 class:ignore_covered_err
96 6 # uncoverable condition right count:2 class:ignore_covered_err
97 # uncoverable condition right count:3 class:ignore_covered_err
98 if (itsv && SvOK(itsv) && SvIV(itsv) > 0) current = (U32)SvIV(itsv);
99 # uncoverable condition right count:2 class:ignore_covered_err
100 # uncoverable condition right count:3 class:ignore_covered_err
101 if (items > i + 1 && SvOK(ST(i + 1)) && SvIV(ST(i + 1)) > 0)
102 current = (U32)SvIV(ST(i + 1));
103 if (items <= i || !SvOK(ST(i))) /* # uncoverable condition left count:1 class:ignore_covered_err */
104 RETVAL = 1; /* no hash at all: rehash */
105 else {
106 s = SvPV(ST(i), sl);
107 RETVAL = pwd_needs_rehash(aTHX_ s, sl, current);
108 }
109 }
110 OUTPUT:
111 RETVAL
112  
113 SV *
114 token(...)
115 CODE:
116 PERL_UNUSED_VAR(items);
117 2 RETVAL = pwd_token(aTHX);
118 OUTPUT:
119 RETVAL
120  
121 SV *
122 token_digest(...)
123 CODE:
124 {
125 6 int i = 0;
126 STRLEN tl;
127 const unsigned char *t;
128 6 ▶ # uncoverable branch true
Branch: 3 branches
BranchTrueFalseTotal
# uncoverable branch true 6 0 6
# uncoverable branch true 6 0 6
# uncoverable branch true 0 6 6
129 0 # uncoverable condition left count:1 class:ignore_covered_err
130 6 ▶ # uncoverable condition right count:1 class:ignore_covered_err
Branch: 2 branches
BranchTrueFalseTotal
# uncoverable condition right count:1 class:ignore_covered_err 6 0 6
# uncoverable condition right count:1 class:ignore_covered_err 0 6 6
131 0 # uncoverable condition left count:2 class:ignore_covered_err
132 6 # uncoverable condition right count:2 class:ignore_covered_err
133 6 # uncoverable condition left count:3 class:ignore_covered_err
134 if (items > i && SvPOK(ST(i)) && sv_derived_from(ST(i), "Punk::Auth::Password"))
135 i++; /* # uncoverable statement */
136 # uncoverable branch true
137 # uncoverable condition left count:1 class:ignore_covered_err
138 # uncoverable condition left count:2 class:ignore_covered_err
139 if (items <= i || !SvOK(ST(i)))
140 croak("Punk::Auth::Password: token_digest needs a token"); /* # uncoverable statement */
141 t = (const unsigned char *)SvPV(ST(i), tl);
142 RETVAL = pwd_token_digest(aTHX_ t, tl);
143 }
144 OUTPUT:
145 RETVAL
« xs/oamount.xs ↑ Summary include/punk/pk_abi_impl.h »