Package list libcryptx-perl / 814312d
backport changes from ecc-ng Karel Miko 3 years ago
3 changed file(s) with 20 addition(s) and 11 deletion(s). Raw diff Collapse all Expand all
1212 system 'rm', '-rf', "$FindBin::Bin/ltc/modes/xts/";
1313 system 'rm', '-rf', "$FindBin::Bin/ltc/pk/katja/";
1414 system 'rm', '-rf', "$FindBin::Bin/ltc/math/gmp_desc.c";
15 find({ wanted=>sub { unlink $_ if $_ =~ /test\.c$/ && $_ !~ /sha3_test.c$/ }, no_chdir=>1 }, "$FindBin::Bin/ltc");
15 find({ wanted=>sub { unlink $_ if -f $_ && $_ =~ /test\.c$/ && $_ !~ /sha3_test.c$/ }, no_chdir=>1 }, "$FindBin::Bin/ltc");
16 find({ wanted=>sub { unlink $_ if -f $_ && $_ =~ /\.o$/ }, no_chdir=>1 }, "$FindBin::Bin/ltm", "$FindBin::Bin/ltc");
1617
1718 #fix modes
1819 warn "gonna chmod..\n";
146146 curve_cofactor => 1,
147147 curve_Gx => "6B17D1F2E12C4247F8BCE6E563A440F277037D812DEB33A0F4A13945D898C296",
148148 curve_Gy => "4FE342E2FE1A7F9B8EE7EB4A7C0F9E162BCE33576B315ECECBB6406837BF51F5",
149 curve_name => "secp256r1",
149 curve_oid => "1.2.840.10045.3.1.7",
150150 curve_order => "FFFFFFFF00000000FFFFFFFFFFFFFFFFBCE6FAADA7179E84F3B9CAC2FC632551",
151151 curve_prime => "FFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFF",
152152 k => "F3BD0C07A81FB932781ED52752F60CC89A6BE5E51934FE01938DDB55D8F77801",
166166 curve_cofactor => 1,
167167 curve_Gx => "6B17D1F2E12C4247F8BCE6E563A440F277037D812DEB33A0F4A13945D898C296",
168168 curve_Gy => "4FE342E2FE1A7F9B8EE7EB4A7C0F9E162BCE33576B315ECECBB6406837BF51F5",
169 curve_name => "secp256r1",
169 curve_oid => "1.2.840.10045.3.1.7",
170170 curve_order => "FFFFFFFF00000000FFFFFFFFFFFFFFFFBCE6FAADA7179E84F3B9CAC2FC632551",
171171 curve_prime => "FFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFF",
172172 k => "",
182182 is($kh->{pub_x}, $EC1->{pub_x}, "EC x test HASH1");
183183 is($kh->{pub_y}, $EC1->{pub_y}, "EC y test HASH1");
184184 is($kh->{k}, $EC1->{k}, "EC k test HASH1");
185 is($kh->{curve_name}, "secp256r1", "EC curve test HASH1");
185 is($kh->{curve_oid}, "1.2.840.10045.3.1.7", "EC curve test HASH1");
186186 ok($ec->is_private, "EC private test HASH1");
187187 my $jwk = $ec->export_key_jwk('private');
188188 my $jwkp = $ec->export_key_jwk('public');
204204 is($kh->{pub_x}, $EC1->{pub_x}, "EC x test JWK1");
205205 is($kh->{pub_y}, $EC1->{pub_y}, "EC y test JWK1");
206206 is($kh->{k}, $EC1->{k}, "EC k test JWK1");
207 is($kh->{curve_name}, "secp256r1", "EC curve test JWK1");
207 is($kh->{curve_oid}, "1.2.840.10045.3.1.7", "EC curve test JWK1");
208208 ok($ec->is_private, "EC private test JWK1");
209209 $jwk_tp = $ec->export_key_jwk_thumbprint('SHA256');
210210 is($jwk_tp, $ec1_jwk_thumbprint_sha256, 'export_key_jwk_thumbprint(SHA256)');
214214 is($kh->{pub_x}, $EC1->{pub_x}, "EC x test JWK2");
215215 is($kh->{pub_y}, $EC1->{pub_y}, "EC y test JWK2");
216216 is($kh->{k}, "", "EC k test JWK2");
217 is($kh->{curve_name}, "secp256r1", "EC curve test JWK2");
217 is($kh->{curve_oid}, "1.2.840.10045.3.1.7", "EC curve test JWK2");
218218 ok(!$ec->is_private, "EC !private test JWK2");
219219 $jwk_tp = $ec->export_key_jwk_thumbprint('SHA256');
220220 is($jwk_tp, $ec1_jwk_thumbprint_sha256, 'export_key_jwk_thumbprint(SHA256)');
226226 is($kh->{pub_x}, $EC1->{pub_x}, "EC x test HASH2");
227227 is($kh->{pub_y}, $EC1->{pub_y}, "EC y test HASH2");
228228 is($kh->{k}, "", "EC k test HASH2");
229 is($kh->{curve_name}, "secp256r1", "EC curve test HASH2");
229 is($kh->{curve_oid}, "1.2.840.10045.3.1.7", "EC curve test HASH2");
230230 ok(!$ec->is_private, "EC private test HASH2");
231231 }
232232
178178 ok($@, 'key not generated');
179179
180180 # known curves lookup
181 my $params = $Crypt::PK::ECC::curve{secp384r1};
181 my $params = { # NIST P-384
182 prime => "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFF0000000000000000FFFFFFFF",
183 A => "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFF0000000000000000FFFFFFFC",
184 B => "B3312FA7E23EE7E4988E056BE3F82D19181D9C6EFE8141120314088F5013875AC656398D8A2ED19D2A85C8EDD3EC2AEF",
185 Gx => "AA87CA22BE8B05378EB1C71EF320AD746E1D3B628BA79B9859F741E082542A385502F25DBF55296C3A545E3872760AB7",
186 Gy => "3617DE4A96262C6F5D9E98BF9292DC29F8F41DBD289A147CE9DA3113B5F0B8C00A60B1CE1D7E819D7A431D7C90EA0E5F",
187 order => "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFC7634D81F4372DDF581A0DB248B0A77AECEC196ACCC52973",
188 cofactor => 1,
189 };
182190 $k = Crypt::PK::ECC->new;
183191 ok($k->generate_key($params), "generate_key hash params");
184192 is($k->key2hash->{curve_name}, 'secp384r1', "key2hash curve_name");
185 is($k->key2hash->{curve_oid}, $params->{oid}, "key2hash curve_oid");
193 is($k->key2hash->{curve_oid}, '1.3.132.0.34', "key2hash curve_oid");
186194 ok($k->export_key_der('private_short'), "export_key_der auto oid");
187195
188196 $k = Crypt::PK::ECC->new;
189 ok($k->generate_key({ %$params, A => '0' }), "generate_key invalid auto oid");
190 is($k->key2hash->{curve_name}, 'custom', "key2hash custom curve_name");
197 ok($k->generate_key({ %$params, cofactor => 6 }), "generate_key invalid auto oid");
198 ok(!exists($k->key2hash->{curve_name}) || $k->key2hash->{curve_name} eq 'custom', "key2hash custom curve_name");
191199 ok(!exists($k->key2hash->{curve_oid}), "key2hash curve_oid doesn't exist");
192200 eval { $k->export_key_der('private_short'); };
193201 ok($@, "export_key_der invalid auto oid");