DES.xs

filter: Statementstmt 80.9% 17 / 21 Branchbran 44.4% 8 / 18 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 64.1% 25 / 39 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« blib/lib/Crypt/DES.pm ↑ Summary _des.c »
1 /*
2 * cross-platform and mod_ssl-safe code modifications are Copyright (C)
3 * 2000 W3Works, LLC. All rights reserved.
4 */
5  
6 /*
7 * Copyright (C) 1995, 1996 Systemics Ltd (http://www.systemics.com/)
8 * All rights reserved.
9 */
10  
11 #include "EXTERN.h"
12 #include "perl.h"
13 #include "XSUB.h"
14  
15 typedef unsigned char i8;
16 typedef unsigned long i32;
17  
18 #include "_des.h"
19  
20 #ifndef sv_undef
21 #define sv_undef PL_sv_undef
22 #endif
23  
24 MODULE = Crypt::DES PACKAGE = Crypt::DES PREFIX = _des_
25 PROTOTYPES: DISABLE
26  
27 char *
28 _des_expand_key(key)
29 char * key = NO_INIT
30 STRLEN key_len = NO_INIT
31 CODE:
32 {
33 des_ks ks;
34  
35 10173 key = (char *) SvPV(ST(0), key_len);
36 10173 ▶ if (key_len != sizeof(des_user_key))
Branch: 1 branch
BranchTrueFalseTotal
if (key_len != sizeof(des_user_key)) 0 10173 10173
37 0 croak("Invalid key");
38  
39 10173 perl_des_expand_key((i8 *)key, ks);
40  
41 10173 ST(0) = sv_2mortal(newSVpv((char *)ks, sizeof(ks)));
42 }
43  
44 void
45 _des_crypt(input, output, ks, enc_flag)
46 char * input = NO_INIT
47 SV * output
48 char * ks = NO_INIT
49 int enc_flag
50 STRLEN input_len = NO_INIT
51 STRLEN output_len = NO_INIT
52 STRLEN ks_len = NO_INIT
53 CODE:
54 {
55 30342 input = (char *) SvPV(ST(0), input_len);
56 30342 ▶ if (input_len != 8)
Branch: 1 branch
BranchTrueFalseTotal
if (input_len != 8) 0 30342 30342
57 0 croak("input must be 8 bytes long");
58  
59 30342 ks = (char *) SvPV(ST(2), ks_len);
60 30342 ▶ if (ks_len != sizeof(des_ks))
Branch: 1 branch
BranchTrueFalseTotal
if (ks_len != sizeof(des_ks)) 0 30342 30342
61 0 croak("Invalid key schedule");
62  
63 30342 ▶ if (output == &sv_undef)
Branch: 1 branch
BranchTrueFalseTotal
if (output == &sv_undef) 0 30342 30342
64 0 output = sv_newmortal();
65 30342 output_len = 8;
66  
67 30342 ▶ (SvUPGRADE(output, SVt_PV));
Branch: 1 branch
BranchTrueFalseTotal
(SvUPGRADE(output, SVt_PV)); 0 30342 30342
68  
69 30342 ▶ perl_des_crypt(input, SvGROW(output, output_len), (i32 *)ks, enc_flag);
Branch: 2 branches
BranchTrueFalseTotal
perl_des_crypt(input, SvGROW(output, output_len), (i32 *)ks, enc_flag); 30342 0 30342
perl_des_crypt(input, SvGROW(output, output_len), (i32 *)ks, enc_flag); 0 30342 30342
70  
71 30342 SvCUR_set(output, output_len);
72 30342 *SvEND(output) = '\0';
73 30342 (void) SvPOK_only(output);
74 30342 ▶ SvTAINT(output);
Branch: 2 branches
BranchTrueFalseTotal
SvTAINT(output); 0 30342 30342
SvTAINT(output); 0 0 0
75  
76 30342 ST(0) = output;
77 }
78  
79  
80  
81  
82  
83  
84  
85  
86  
87  
88  
89  
« blib/lib/Crypt/DES.pm ↑ Summary _des.c »