File Coverage

DES.xs
Criterion Covered Total %
statement 16 21 76.2
branch n/a
condition n/a
subroutine n/a
pod n/a
total 16 21 76.2


line stmt bran cond sub pod time code
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 10175           key = (char *) SvPV(ST(0), key_len);
36 10175           if (key_len != sizeof(des_user_key))
37 0           croak("Invalid key");
38            
39 10175           perl_des_expand_key((i8 *)key, ks);
40            
41 10175           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 30350           input = (char *) SvPV(ST(0), input_len);
56 30350           if (input_len != 8)
57 0           croak("input must be 8 bytes long");
58            
59 30350           ks = (char *) SvPV(ST(2), ks_len);
60 30350           if (ks_len != sizeof(des_ks))
61 0           croak("Invalid key schedule");
62            
63 30350           if (output == &sv_undef)
64 0           output = sv_newmortal();
65             output_len = 8;
66            
67 30350           if (!SvUPGRADE(output, SVt_PV))
68 0           croak("cannot use output argument as lvalue");
69            
70 30350           perl_des_crypt(input, SvGROW(output, output_len), (i32 *)ks, enc_flag);
71            
72 30350           SvCUR_set(output, output_len);
73 30350           *SvEND(output) = '\0';
74 30350           (void) SvPOK_only(output);
75 30350           SvTAINT(output);
76            
77 30350           ST(0) = output;
78             }
79            
80            
81            
82            
83            
84            
85            
86            
87            
88            
89            
90            
91