preparing 0.017
Karel Miko
10 years ago
61 | 61 | c_source => 'src', |
62 | 62 | requires => { |
63 | 63 | 'perl' => '5.006', |
64 | 'MIME::Base64' => '3.11', # we need: encode_base64url | |
64 | 'MIME::Base64' => 0, | |
65 | 65 | 'Exporter' => '5.59', # we need: use Exporter 'import'; |
66 | 66 | }, |
67 | 67 | build_requires => { |
68 | 68 | 'Module::Build' => 0, |
69 | 'MIME::Base64' => '3.11', # we need: encode_base64url | |
69 | 'MIME::Base64' => 0, | |
70 | 70 | 'Test::More' => '0.88', # we need: done_testing |
71 | 71 | 'File::Find' => 0, |
72 | 72 | }, |
9 | 9 | - misc patches |
10 | 10 | https://secure.ucc.asn.au/hg/dropbear/rev/9a789fc03f40?revcount=240 |
11 | 11 | |
12 | 0.016_2 2013/09/23 | |
12 | 0.017 2013/09/24 | |
13 | - lowering MIME::Base64 version requirement | |
13 | 14 | - support for import/export of password protected RSA/DSA keys |
14 | 15 | - RSA: added - export_key_pem('public_x509') |
15 | 16 | - better handling of dh_free/rsa_free/dsa_free/ecc_free |
16 | 17 | - added openssl test vectors |
18 | - fixing compiler warnings (RSA/DSA/ECC/DH) | |
17 | 19 | |
18 | 20 | 0.016 2013/09/15 |
19 | 21 | - added missing test for key2hash, sign_hash, verify_hash |
8 | 8 | our @EXPORT = qw(); |
9 | 9 | |
10 | 10 | use CryptX; |
11 | use MIME::Base64 qw(encode_base64 encode_base64url); | |
11 | use MIME::Base64 qw(encode_base64); | |
12 | 12 | |
13 | 13 | sub _trans_prng_name { |
14 | 14 | my $name = shift; |
34 | 34 | |
35 | 35 | sub bytes_b64 { return encode_base64(shift->bytes(shift), "") } |
36 | 36 | |
37 | sub bytes_b64u { return encode_base64url(shift->bytes(shift), "") } | |
37 | sub bytes_b64u { return _base64url_enc(shift->bytes(shift), "") } | |
38 | 38 | |
39 | 39 | sub string { |
40 | 40 | my ($self, $len) = @_; |
89 | 89 | sub random_string { return $fetch_RNG->()->string(@_) } |
90 | 90 | } |
91 | 91 | |
92 | # Base64 URL Safe hack as encode_base64url requires MIME::Base64 3.11+ | |
93 | sub _base64url_enc { | |
94 | # RFC 4648 Base64 URL Safe - https://tools.ietf.org/html/rfc4648#page-7 | |
95 | my $data = shift; | |
96 | my $b64 = encode_base64($data, ''); | |
97 | $b64 =~ s/=+\z//; | |
98 | $b64 =~ tr[+/][-_]; | |
99 | return $b64; | |
100 | } | |
101 | ||
92 | 102 | 1; |
93 | 103 | |
94 | 104 | =pod |
2 | 2 | use strict; |
3 | 3 | use warnings ; |
4 | 4 | |
5 | our $VERSION = '0.016_3'; | |
5 | our $VERSION = '0.016_4'; | |
6 | 6 | |
7 | 7 | require XSLoader; |
8 | 8 | XSLoader::load('CryptX', $VERSION); |
65 | 65 | PREINIT: |
66 | 66 | HV *rv_hash; |
67 | 67 | long siz; |
68 | unsigned char buf[20001]; | |
68 | char buf[20001]; | |
69 | SV **not_used; | |
69 | 70 | CODE: |
70 | 71 | if (self->key.type == -1) XSRETURN_UNDEF; |
71 | 72 | rv_hash = newHV(); |
76 | 77 | } |
77 | 78 | if (siz>0) { |
78 | 79 | mp_tohex(self->key.x, buf); |
79 | hv_store(rv_hash, "x", 1, newSVpv(buf, strlen(buf)), 0); | |
80 | not_used = hv_store(rv_hash, "x", 1, newSVpv(buf, strlen(buf)), 0); | |
80 | 81 | } |
81 | 82 | else{ |
82 | hv_store(rv_hash, "x", 1, newSVpv("", 0), 0); | |
83 | not_used = hv_store(rv_hash, "x", 1, newSVpv("", 0), 0); | |
83 | 84 | } |
84 | 85 | /* =====> y */ |
85 | 86 | siz = (self->key.y) ? ltc_mp.unsigned_size(self->key.y) : 0; |
88 | 89 | } |
89 | 90 | if (siz>0) { |
90 | 91 | mp_tohex(self->key.y, buf); |
91 | hv_store(rv_hash, "y", 1, newSVpv(buf, strlen(buf)), 0); | |
92 | not_used = hv_store(rv_hash, "y", 1, newSVpv(buf, strlen(buf)), 0); | |
92 | 93 | } |
93 | 94 | else{ |
94 | hv_store(rv_hash, "y", 1, newSVpv("", 0), 0); | |
95 | not_used = hv_store(rv_hash, "y", 1, newSVpv("", 0), 0); | |
95 | 96 | } |
96 | 97 | /* =====> name */ |
97 | 98 | snprintf(buf, sizeof(buf), "DH-%d", dh_get_size(&self->key)*8); |
98 | hv_store(rv_hash, "name", 4, newSVpv(buf, strlen(buf)), 0); | |
99 | not_used = hv_store(rv_hash, "name", 4, newSVpv(buf, strlen(buf)), 0); | |
99 | 100 | /* =====> size */ |
100 | hv_store(rv_hash, "size", 4, newSViv(dh_get_size(&self->key)), 0); | |
101 | not_used = hv_store(rv_hash, "size", 4, newSViv(dh_get_size(&self->key)), 0); | |
101 | 102 | /* =====> type */ |
102 | hv_store(rv_hash, "type", 4, newSViv(self->key.type), 0); | |
103 | not_used = hv_store(rv_hash, "type", 4, newSViv(self->key.type), 0); | |
104 | if (not_used) not_used = NULL; /* just silence the warning: variable 'not_used' set but not used */ | |
103 | 105 | RETVAL = newRV_noinc((SV*)rv_hash); |
104 | 106 | OUTPUT: |
105 | 107 | RETVAL |
73 | 73 | PREINIT: |
74 | 74 | HV *rv_hash; |
75 | 75 | long siz; |
76 | unsigned char buf[20001]; | |
76 | char buf[20001]; | |
77 | SV **not_used; | |
77 | 78 | CODE: |
78 | 79 | if (self->key.type == -1 || self->key.qord <= 0) XSRETURN_UNDEF; |
79 | 80 | rv_hash = newHV(); |
84 | 85 | } |
85 | 86 | if (siz>0) { |
86 | 87 | mp_tohex(self->key.g, buf); |
87 | hv_store(rv_hash, "g", 1, newSVpv(buf, strlen(buf)), 0); | |
88 | } | |
89 | else{ | |
90 | hv_store(rv_hash, "g", 1, newSVpv("", 0), 0); | |
88 | not_used = hv_store(rv_hash, "g", 1, newSVpv(buf, strlen(buf)), 0); | |
89 | } | |
90 | else{ | |
91 | not_used = hv_store(rv_hash, "g", 1, newSVpv("", 0), 0); | |
91 | 92 | } |
92 | 93 | /* =====> q */ |
93 | 94 | siz = (self->key.q) ? ltc_mp.unsigned_size(self->key.q) : 0; |
96 | 97 | } |
97 | 98 | if (siz>0) { |
98 | 99 | mp_tohex(self->key.q, buf); |
99 | hv_store(rv_hash, "q", 1, newSVpv(buf, strlen(buf)), 0); | |
100 | } | |
101 | else{ | |
102 | hv_store(rv_hash, "q", 1, newSVpv("", 0), 0); | |
100 | not_used = hv_store(rv_hash, "q", 1, newSVpv(buf, strlen(buf)), 0); | |
101 | } | |
102 | else{ | |
103 | not_used = hv_store(rv_hash, "q", 1, newSVpv("", 0), 0); | |
103 | 104 | } |
104 | 105 | /* =====> p */ |
105 | 106 | siz = (self->key.p) ? ltc_mp.unsigned_size(self->key.p) : 0; |
108 | 109 | } |
109 | 110 | if (siz>0) { |
110 | 111 | mp_tohex(self->key.p, buf); |
111 | hv_store(rv_hash, "p", 1, newSVpv(buf, strlen(buf)), 0); | |
112 | } | |
113 | else{ | |
114 | hv_store(rv_hash, "p", 1, newSVpv("", 0), 0); | |
112 | not_used = hv_store(rv_hash, "p", 1, newSVpv(buf, strlen(buf)), 0); | |
113 | } | |
114 | else{ | |
115 | not_used = hv_store(rv_hash, "p", 1, newSVpv("", 0), 0); | |
115 | 116 | } |
116 | 117 | /* =====> x */ |
117 | 118 | siz = (self->key.x) ? ltc_mp.unsigned_size(self->key.x) : 0; |
120 | 121 | } |
121 | 122 | if (siz>0) { |
122 | 123 | mp_tohex(self->key.x, buf); |
123 | hv_store(rv_hash, "x", 1, newSVpv(buf, strlen(buf)), 0); | |
124 | } | |
125 | else{ | |
126 | hv_store(rv_hash, "x", 1, newSVpv("", 0), 0); | |
124 | not_used = hv_store(rv_hash, "x", 1, newSVpv(buf, strlen(buf)), 0); | |
125 | } | |
126 | else{ | |
127 | not_used = hv_store(rv_hash, "x", 1, newSVpv("", 0), 0); | |
127 | 128 | } |
128 | 129 | /* =====> y */ |
129 | 130 | siz = (self->key.y) ? ltc_mp.unsigned_size(self->key.y) : 0; |
132 | 133 | } |
133 | 134 | if (siz>0) { |
134 | 135 | mp_tohex(self->key.y, buf); |
135 | hv_store(rv_hash, "y", 1, newSVpv(buf, strlen(buf)), 0); | |
136 | } | |
137 | else{ | |
138 | hv_store(rv_hash, "y", 1, newSVpv("", 0), 0); | |
136 | not_used = hv_store(rv_hash, "y", 1, newSVpv(buf, strlen(buf)), 0); | |
137 | } | |
138 | else{ | |
139 | not_used = hv_store(rv_hash, "y", 1, newSVpv("", 0), 0); | |
139 | 140 | } |
140 | 141 | /* =====> size */ |
141 | hv_store(rv_hash, "size", 4, newSViv(ltc_mp.unsigned_size(self->key.q)), 0); | |
142 | not_used = hv_store(rv_hash, "size", 4, newSViv(ltc_mp.unsigned_size(self->key.q)), 0); | |
142 | 143 | /* =====> type */ |
143 | hv_store(rv_hash, "type", 4, newSViv(self->key.type), 0); | |
144 | not_used = hv_store(rv_hash, "type", 4, newSViv(self->key.type), 0); | |
145 | if (not_used) not_used = NULL; /* just silence the warning: variable 'not_used' set but not used */ | |
144 | 146 | RETVAL = newRV_noinc((SV*)rv_hash); |
145 | 147 | OUTPUT: |
146 | 148 | RETVAL |
82 | 82 | PREINIT: |
83 | 83 | HV *rv_hash; |
84 | 84 | long siz; |
85 | unsigned char buf[20001]; | |
85 | char buf[20001]; | |
86 | SV **not_used; | |
86 | 87 | CODE: |
87 | 88 | if (self->key.type == -1) XSRETURN_UNDEF; |
88 | 89 | rv_hash = newHV(); |
93 | 94 | } |
94 | 95 | if (siz>0) { |
95 | 96 | mp_tohex(self->key.k, buf); |
96 | hv_store(rv_hash, "k", 1, newSVpv(buf, strlen(buf)), 0); | |
97 | not_used = hv_store(rv_hash, "k", 1, newSVpv(buf, strlen(buf)), 0); | |
97 | 98 | } |
98 | 99 | else{ |
99 | hv_store(rv_hash, "k", 1, newSVpv("", 0), 0); | |
100 | not_used = hv_store(rv_hash, "k", 1, newSVpv("", 0), 0); | |
100 | 101 | } |
101 | 102 | /* =====> pub_x */ |
102 | 103 | siz = (self->key.pubkey.x) ? ltc_mp.unsigned_size(self->key.pubkey.x) : 0; |
105 | 106 | } |
106 | 107 | if (siz>0) { |
107 | 108 | mp_tohex(self->key.pubkey.x, buf); |
108 | hv_store(rv_hash, "pub_x", 5, newSVpv(buf, strlen(buf)), 0); | |
109 | not_used = hv_store(rv_hash, "pub_x", 5, newSVpv(buf, strlen(buf)), 0); | |
109 | 110 | } |
110 | 111 | else{ |
111 | hv_store(rv_hash, "pub_x", 5, newSVpv("", 0), 0); | |
112 | not_used = hv_store(rv_hash, "pub_x", 5, newSVpv("", 0), 0); | |
112 | 113 | } |
113 | 114 | /* =====> pub_y */ |
114 | 115 | siz = (self->key.pubkey.y) ? ltc_mp.unsigned_size(self->key.pubkey.y) : 0; |
117 | 118 | } |
118 | 119 | if (siz>0) { |
119 | 120 | mp_tohex(self->key.pubkey.y, buf); |
120 | hv_store(rv_hash, "pub_y", 5, newSVpv(buf, strlen(buf)), 0); | |
121 | not_used = hv_store(rv_hash, "pub_y", 5, newSVpv(buf, strlen(buf)), 0); | |
121 | 122 | } |
122 | 123 | else{ |
123 | hv_store(rv_hash, "pub_y", 5, newSVpv("", 0), 0); | |
124 | not_used = hv_store(rv_hash, "pub_y", 5, newSVpv("", 0), 0); | |
124 | 125 | } |
125 | 126 | /* =====> pub_z */ |
126 | 127 | siz = (self->key.pubkey.z) ? ltc_mp.unsigned_size(self->key.pubkey.z) : 0; |
129 | 130 | } |
130 | 131 | if (siz>0) { |
131 | 132 | mp_tohex(self->key.pubkey.z, buf); |
132 | hv_store(rv_hash, "pub_z", 5, newSVpv(buf, strlen(buf)), 0); | |
133 | not_used = hv_store(rv_hash, "pub_z", 5, newSVpv(buf, strlen(buf)), 0); | |
133 | 134 | } |
134 | 135 | else{ |
135 | hv_store(rv_hash, "pub_z", 5, newSVpv("", 0), 0); | |
136 | not_used = hv_store(rv_hash, "pub_z", 5, newSVpv("", 0), 0); | |
136 | 137 | } |
137 | 138 | /* =====> curve_... */ |
138 | 139 | if (self->key.idx>=0) { |
139 | hv_store(rv_hash, "curve_name", 10, newSVpv(self->key.dp->name, strlen(self->key.dp->name)), 0); | |
140 | hv_store(rv_hash, "curve_prime", 11, newSVpv(self->key.dp->prime, strlen(self->key.dp->prime)), 0); | |
141 | hv_store(rv_hash, "curve_B", 7, newSVpv(self->key.dp->B, strlen(self->key.dp->B)), 0); | |
142 | hv_store(rv_hash, "curve_order", 11, newSVpv(self->key.dp->order, strlen(self->key.dp->order)), 0); | |
143 | hv_store(rv_hash, "curve_Gx", 8, newSVpv(self->key.dp->Gx, strlen(self->key.dp->Gx)), 0); | |
144 | hv_store(rv_hash, "curve_Gy", 8, newSVpv(self->key.dp->Gy, strlen(self->key.dp->Gy)), 0); | |
145 | hv_store(rv_hash, "curve_size", 10, newSViv(self->key.dp->size), 0); | |
140 | not_used = hv_store(rv_hash, "curve_name", 10, newSVpv(self->key.dp->name, strlen(self->key.dp->name)), 0); | |
141 | not_used = hv_store(rv_hash, "curve_prime", 11, newSVpv(self->key.dp->prime, strlen(self->key.dp->prime)), 0); | |
142 | not_used = hv_store(rv_hash, "curve_B", 7, newSVpv(self->key.dp->B, strlen(self->key.dp->B)), 0); | |
143 | not_used = hv_store(rv_hash, "curve_order", 11, newSVpv(self->key.dp->order, strlen(self->key.dp->order)), 0); | |
144 | not_used = hv_store(rv_hash, "curve_Gx", 8, newSVpv(self->key.dp->Gx, strlen(self->key.dp->Gx)), 0); | |
145 | not_used = hv_store(rv_hash, "curve_Gy", 8, newSVpv(self->key.dp->Gy, strlen(self->key.dp->Gy)), 0); | |
146 | not_used = hv_store(rv_hash, "curve_size", 10, newSViv(self->key.dp->size), 0); | |
146 | 147 | } |
147 | 148 | /* =====> size */ |
148 | hv_store(rv_hash, "size", 4, newSViv(ecc_get_size(&self->key)), 0); | |
149 | not_used = hv_store(rv_hash, "size", 4, newSViv(ecc_get_size(&self->key)), 0); | |
149 | 150 | /* =====> type */ |
150 | hv_store(rv_hash, "type", 4, newSViv(self->key.type), 0); | |
151 | not_used = hv_store(rv_hash, "type", 4, newSViv(self->key.type), 0); | |
152 | if (not_used) not_used = NULL; /* just silence the warning: variable 'not_used' set but not used */ | |
151 | 153 | RETVAL = newRV_noinc((SV*)rv_hash); |
152 | 154 | OUTPUT: |
153 | 155 | RETVAL |
66 | 66 | PREINIT: |
67 | 67 | HV *rv_hash; |
68 | 68 | long siz; |
69 | unsigned char buf[20001]; | |
69 | char buf[20001]; | |
70 | SV **not_used; | |
70 | 71 | CODE: |
71 | 72 | if (self->key.type == -1 || self->key.N == NULL) XSRETURN_UNDEF; |
72 | 73 | rv_hash = newHV(); |
77 | 78 | } |
78 | 79 | if (siz>0) { |
79 | 80 | mp_tohex(self->key.e, buf); |
80 | hv_store(rv_hash, "e", 1, newSVpv(buf, strlen(buf)), 0); | |
81 | } | |
82 | else{ | |
83 | hv_store(rv_hash, "e", 1, newSVpv("", 0), 0); | |
81 | not_used = hv_store(rv_hash, "e", 1, newSVpv(buf, strlen(buf)), 0); | |
82 | } | |
83 | else{ | |
84 | not_used = hv_store(rv_hash, "e", 1, newSVpv("", 0), 0); | |
84 | 85 | } |
85 | 86 | /* =====> d */ |
86 | 87 | siz = (self->key.d) ? ltc_mp.unsigned_size(self->key.d) : 0; |
89 | 90 | } |
90 | 91 | if (siz>0) { |
91 | 92 | mp_tohex(self->key.d, buf); |
92 | hv_store(rv_hash, "d", 1, newSVpv(buf, strlen(buf)), 0); | |
93 | } | |
94 | else{ | |
95 | hv_store(rv_hash, "d", 1, newSVpv("", 0), 0); | |
93 | not_used = hv_store(rv_hash, "d", 1, newSVpv(buf, strlen(buf)), 0); | |
94 | } | |
95 | else{ | |
96 | not_used = hv_store(rv_hash, "d", 1, newSVpv("", 0), 0); | |
96 | 97 | } |
97 | 98 | /* =====> N */ |
98 | 99 | siz = (self->key.N) ? ltc_mp.unsigned_size(self->key.N) : 0; |
101 | 102 | } |
102 | 103 | if (siz>0) { |
103 | 104 | mp_tohex(self->key.N, buf); |
104 | hv_store(rv_hash, "N", 1, newSVpv(buf, strlen(buf)), 0); | |
105 | } | |
106 | else{ | |
107 | hv_store(rv_hash, "N", 1, newSVpv("", 0), 0); | |
105 | not_used = hv_store(rv_hash, "N", 1, newSVpv(buf, strlen(buf)), 0); | |
106 | } | |
107 | else{ | |
108 | not_used = hv_store(rv_hash, "N", 1, newSVpv("", 0), 0); | |
108 | 109 | } |
109 | 110 | /* =====> q */ |
110 | 111 | siz = (self->key.q) ? ltc_mp.unsigned_size(self->key.q) : 0; |
113 | 114 | } |
114 | 115 | if (siz>0) { |
115 | 116 | mp_tohex(self->key.q, buf); |
116 | hv_store(rv_hash, "q", 1, newSVpv(buf, strlen(buf)), 0); | |
117 | } | |
118 | else{ | |
119 | hv_store(rv_hash, "q", 1, newSVpv("", 0), 0); | |
117 | not_used = hv_store(rv_hash, "q", 1, newSVpv(buf, strlen(buf)), 0); | |
118 | } | |
119 | else{ | |
120 | not_used = hv_store(rv_hash, "q", 1, newSVpv("", 0), 0); | |
120 | 121 | } |
121 | 122 | /* =====> p */ |
122 | 123 | siz = (self->key.p) ? ltc_mp.unsigned_size(self->key.p) : 0; |
125 | 126 | } |
126 | 127 | if (siz>0) { |
127 | 128 | mp_tohex(self->key.p, buf); |
128 | hv_store(rv_hash, "p", 1, newSVpv(buf, strlen(buf)), 0); | |
129 | } | |
130 | else{ | |
131 | hv_store(rv_hash, "p", 1, newSVpv("", 0), 0); | |
129 | not_used = hv_store(rv_hash, "p", 1, newSVpv(buf, strlen(buf)), 0); | |
130 | } | |
131 | else{ | |
132 | not_used = hv_store(rv_hash, "p", 1, newSVpv("", 0), 0); | |
132 | 133 | } |
133 | 134 | /* =====> qP */ |
134 | 135 | siz = (self->key.qP) ? ltc_mp.unsigned_size(self->key.qP) : 0; |
137 | 138 | } |
138 | 139 | if (siz>0) { |
139 | 140 | mp_tohex(self->key.qP, buf); |
140 | hv_store(rv_hash, "qP", 2, newSVpv(buf, strlen(buf)), 0); | |
141 | } | |
142 | else{ | |
143 | hv_store(rv_hash, "qP", 2, newSVpv("", 0), 0); | |
141 | not_used = hv_store(rv_hash, "qP", 2, newSVpv(buf, strlen(buf)), 0); | |
142 | } | |
143 | else{ | |
144 | not_used = hv_store(rv_hash, "qP", 2, newSVpv("", 0), 0); | |
144 | 145 | } |
145 | 146 | /* =====> dP */ |
146 | 147 | siz = (self->key.dP) ? ltc_mp.unsigned_size(self->key.dP) : 0; |
149 | 150 | } |
150 | 151 | if (siz>0) { |
151 | 152 | mp_tohex(self->key.dP, buf); |
152 | hv_store(rv_hash, "dP", 2, newSVpv(buf, strlen(buf)), 0); | |
153 | } | |
154 | else{ | |
155 | hv_store(rv_hash, "dP", 2, newSVpv("", 0), 0); | |
153 | not_used = hv_store(rv_hash, "dP", 2, newSVpv(buf, strlen(buf)), 0); | |
154 | } | |
155 | else{ | |
156 | not_used = hv_store(rv_hash, "dP", 2, newSVpv("", 0), 0); | |
156 | 157 | } |
157 | 158 | /* =====> dQ */ |
158 | 159 | siz = (self->key.dQ) ? ltc_mp.unsigned_size(self->key.dQ) : 0; |
161 | 162 | } |
162 | 163 | if (siz>0) { |
163 | 164 | mp_tohex(self->key.dQ, buf); |
164 | hv_store(rv_hash, "dQ", 2, newSVpv(buf, strlen(buf)), 0); | |
165 | } | |
166 | else{ | |
167 | hv_store(rv_hash, "dQ", 2, newSVpv("", 0), 0); | |
165 | not_used = hv_store(rv_hash, "dQ", 2, newSVpv(buf, strlen(buf)), 0); | |
166 | } | |
167 | else{ | |
168 | not_used = hv_store(rv_hash, "dQ", 2, newSVpv("", 0), 0); | |
168 | 169 | } |
169 | 170 | /* =====> size */ |
170 | hv_store(rv_hash, "size", 4, newSViv(ltc_mp.unsigned_size(self->key.N)), 0); | |
171 | not_used = hv_store(rv_hash, "size", 4, newSViv(ltc_mp.unsigned_size(self->key.N)), 0); | |
171 | 172 | /* =====> type */ |
172 | hv_store(rv_hash, "type", 4, newSViv(self->key.type), 0); | |
173 | not_used = hv_store(rv_hash, "type", 4, newSViv(self->key.type), 0); | |
174 | if (not_used) not_used = NULL; /* just silence the warning: variable 'not_used' set but not used */ | |
173 | 175 | RETVAL = newRV_noinc((SV*)rv_hash); |
174 | 176 | OUTPUT: |
175 | 177 | RETVAL |
535 | 535 | { |
536 | 536 | ulong64 L, R; |
537 | 537 | ulong32 a, b; |
538 | int i; | |
539 | typedef union { | |
540 | ulong64 l; | |
541 | unsigned char c[8]; | |
542 | } xxx; | |
543 | xxx D; | |
544 | 538 | |
545 | 539 | LOAD64H(R, ct+0); LOAD64H(L, ct+8); |
546 | //fprintf(stderr,"01:"); D.l = R; for(i=7;i>=0;i--) fprintf(stderr, "%x",D.c[i]); D.l = L; for(i=7;i>=0;i--) fprintf(stderr, "%x",D.c[i]); fprintf(stderr,"\n"); | |
547 | 540 | L ^= skey->camellia.kw[3]; |
548 | 541 | R ^= skey->camellia.kw[2]; |
549 | 542 |
66 | 66 | 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, |
67 | 67 | 255, 255, 255, 255 }; |
68 | 68 | |
69 | /** | |
70 | base64 decode a block of memory | |
71 | @param in The base64 data to decode | |
72 | @param inlen The length of the base64 data | |
73 | @param out [out] The destination of the binary decoded data | |
74 | @param outlen [in/out] The max size and resulting size of the decoded data | |
75 | @return CRYPT_OK if successful | |
76 | */ | |
77 | int base64_decode(const unsigned char *in, unsigned long inlen, | |
78 | unsigned char *out, unsigned long *outlen) | |
79 | { | |
80 | return base64_decode_internal(in, inlen, out, outlen, map_base64); | |
81 | } | |
82 | ||
83 | /** | |
84 | base64 (URL Safe, RFC 4648 section 5) decode a block of memory | |
85 | @param in The base64 data to decode | |
86 | @param inlen The length of the base64 data | |
87 | @param out [out] The destination of the binary decoded data | |
88 | @param outlen [in/out] The max size and resulting size of the decoded data | |
89 | @return CRYPT_OK if successful | |
90 | */ | |
91 | int base64url_decode(const unsigned char *in, unsigned long inlen, | |
92 | unsigned char *out, unsigned long *outlen) | |
93 | { | |
94 | return base64_decode_internal(in, inlen, out, outlen, map_base64url); | |
95 | } | |
96 | ||
97 | 69 | int base64_decode_internal(const unsigned char *in, unsigned long inlen, |
98 | 70 | unsigned char *out, unsigned long *outlen, |
99 | 71 | const unsigned char *map) |
141 | 113 | return CRYPT_OK; |
142 | 114 | } |
143 | 115 | |
116 | /** | |
117 | base64 decode a block of memory | |
118 | @param in The base64 data to decode | |
119 | @param inlen The length of the base64 data | |
120 | @param out [out] The destination of the binary decoded data | |
121 | @param outlen [in/out] The max size and resulting size of the decoded data | |
122 | @return CRYPT_OK if successful | |
123 | */ | |
124 | int base64_decode(const unsigned char *in, unsigned long inlen, | |
125 | unsigned char *out, unsigned long *outlen) | |
126 | { | |
127 | return base64_decode_internal(in, inlen, out, outlen, map_base64); | |
128 | } | |
129 | ||
130 | /** | |
131 | base64 (URL Safe, RFC 4648 section 5) decode a block of memory | |
132 | @param in The base64 data to decode | |
133 | @param inlen The length of the base64 data | |
134 | @param out [out] The destination of the binary decoded data | |
135 | @param outlen [in/out] The max size and resulting size of the decoded data | |
136 | @return CRYPT_OK if successful | |
137 | */ | |
138 | int base64url_decode(const unsigned char *in, unsigned long inlen, | |
139 | unsigned char *out, unsigned long *outlen) | |
140 | { | |
141 | return base64_decode_internal(in, inlen, out, outlen, map_base64url); | |
142 | } | |
143 | ||
144 | 144 | #endif |
145 | 145 | |
146 | 146 |
23 | 23 | |
24 | 24 | static const char *codes_base64url = |
25 | 25 | "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"; |
26 | ||
27 | /** | |
28 | base64 Encode a buffer (NUL terminated) | |
29 | @param in The input buffer to encode | |
30 | @param inlen The length of the input buffer | |
31 | @param out [out] The destination of the base64 encoded data | |
32 | @param outlen [in/out] The max size and resulting size | |
33 | @return CRYPT_OK if successful | |
34 | */ | |
35 | int base64_encode(const unsigned char *in, unsigned long inlen, | |
36 | unsigned char *out, unsigned long *outlen) | |
37 | { | |
38 | return base64_encode_internal(in, inlen, out, outlen, codes_base64, 1); | |
39 | } | |
40 | ||
41 | /** | |
42 | base64 (URL Safe, RFC 4648 section 5) Encode a buffer (NUL terminated) | |
43 | @param in The input buffer to encode | |
44 | @param inlen The length of the input buffer | |
45 | @param out [out] The destination of the base64 encoded data | |
46 | @param outlen [in/out] The max size and resulting size | |
47 | @return CRYPT_OK if successful | |
48 | */ | |
49 | int base64url_encode(const unsigned char *in, unsigned long inlen, | |
50 | unsigned char *out, unsigned long *outlen) | |
51 | { | |
52 | return base64_encode_internal(in, inlen, out, outlen, codes_base64url, 0); | |
53 | } | |
54 | 26 | |
55 | 27 | int base64_encode_internal(const unsigned char *in, unsigned long inlen, |
56 | 28 | unsigned char *out, unsigned long *outlen, |
102 | 74 | return CRYPT_OK; |
103 | 75 | } |
104 | 76 | |
77 | /** | |
78 | base64 Encode a buffer (NUL terminated) | |
79 | @param in The input buffer to encode | |
80 | @param inlen The length of the input buffer | |
81 | @param out [out] The destination of the base64 encoded data | |
82 | @param outlen [in/out] The max size and resulting size | |
83 | @return CRYPT_OK if successful | |
84 | */ | |
85 | int base64_encode(const unsigned char *in, unsigned long inlen, | |
86 | unsigned char *out, unsigned long *outlen) | |
87 | { | |
88 | return base64_encode_internal(in, inlen, out, outlen, codes_base64, 1); | |
89 | } | |
90 | ||
91 | /** | |
92 | base64 (URL Safe, RFC 4648 section 5) Encode a buffer (NUL terminated) | |
93 | @param in The input buffer to encode | |
94 | @param inlen The length of the input buffer | |
95 | @param out [out] The destination of the base64 encoded data | |
96 | @param outlen [in/out] The max size and resulting size | |
97 | @return CRYPT_OK if successful | |
98 | */ | |
99 | int base64url_encode(const unsigned char *in, unsigned long inlen, | |
100 | unsigned char *out, unsigned long *outlen) | |
101 | { | |
102 | return base64_encode_internal(in, inlen, out, outlen, codes_base64url, 0); | |
103 | } | |
104 | ||
105 | 105 | #endif |
106 | 106 | |
107 | 107 |