Mercurial > trustbridge
annotate ui/tests/commontest.cpp @ 359:f6ce186cebc2
If DO_RELEASE_BUILD is set use pubkey-release and test with it
This currently fails because polarssl rejects keys with
a public exponent larger then 64 bit.
With the following patch all tests pass. But this
currently awaits upstream comment.
https://polarssl.org/discussions/bug-report-issues/rsa-keys-with-large-public-exponents-are-rejected
--- rsa.c.orig 2014-04-10 17:22:32.727290031 +0200
+++ rsa.c 2014-04-10 17:22:38.847410225 +0200
@@ -154,7 +154,7 @@
return( POLARSSL_ERR_RSA_KEY_CHECK_FAILED );
if( mpi_msb( &ctx->E ) < 2 ||
- mpi_msb( &ctx->E ) > 64 )
+ mpi_msb( &ctx->E ) > POLARSSL_MPI_MAX_BITS )
return( POLARSSL_ERR_RSA_KEY_CHECK_FAILED );
return( 0 );
author | Andre Heinecke <andre.heinecke@intevation.de> |
---|---|
date | Thu, 10 Apr 2014 17:50:44 +0200 |
parents | 6b4ad6ccc48e |
children | 17e1c8f37d72 |
rev | line source |
---|---|
182
6c3a089d3265
Add test for str_base64_decode as i suspect it to have a bug
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
1 #include <QString> |
6c3a089d3265
Add test for str_base64_decode as i suspect it to have a bug
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
2 #include <QByteArray> |
6c3a089d3265
Add test for str_base64_decode as i suspect it to have a bug
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
3 #include <QTest> |
6c3a089d3265
Add test for str_base64_decode as i suspect it to have a bug
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
4 |
6c3a089d3265
Add test for str_base64_decode as i suspect it to have a bug
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
5 #include "commontest.h" |
6c3a089d3265
Add test for str_base64_decode as i suspect it to have a bug
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
6 #include "strhelp.h" |
6c3a089d3265
Add test for str_base64_decode as i suspect it to have a bug
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
7 |
237
6435e28ae753
Properly test for invalid input
Andre Heinecke <aheinecke@intevation.de>
parents:
233
diff
changeset
|
8 void CommonTest::testInvalidInput() { |
6435e28ae753
Properly test for invalid input
Andre Heinecke <aheinecke@intevation.de>
parents:
233
diff
changeset
|
9 const char * foo = "Zm9vA"; /* Invalid input with a bit valid input */ |
6435e28ae753
Properly test for invalid input
Andre Heinecke <aheinecke@intevation.de>
parents:
233
diff
changeset
|
10 char *data = NULL; |
6435e28ae753
Properly test for invalid input
Andre Heinecke <aheinecke@intevation.de>
parents:
233
diff
changeset
|
11 size_t data_size = 0; |
6435e28ae753
Properly test for invalid input
Andre Heinecke <aheinecke@intevation.de>
parents:
233
diff
changeset
|
12 int ret = -1; |
6435e28ae753
Properly test for invalid input
Andre Heinecke <aheinecke@intevation.de>
parents:
233
diff
changeset
|
13 ret = str_base64_decode(&data, &data_size, (char *)foo, 5); |
6435e28ae753
Properly test for invalid input
Andre Heinecke <aheinecke@intevation.de>
parents:
233
diff
changeset
|
14 |
239
6b4ad6ccc48e
Change the specification of str_b64_decode so that it matches the
Andre Heinecke <aheinecke@intevation.de>
parents:
237
diff
changeset
|
15 QVERIFY(ret == 0); |
6b4ad6ccc48e
Change the specification of str_b64_decode so that it matches the
Andre Heinecke <aheinecke@intevation.de>
parents:
237
diff
changeset
|
16 QVERIFY(data == QString::fromLatin1("foo")); |
237
6435e28ae753
Properly test for invalid input
Andre Heinecke <aheinecke@intevation.de>
parents:
233
diff
changeset
|
17 free(data); |
6435e28ae753
Properly test for invalid input
Andre Heinecke <aheinecke@intevation.de>
parents:
233
diff
changeset
|
18 } |
6435e28ae753
Properly test for invalid input
Andre Heinecke <aheinecke@intevation.de>
parents:
233
diff
changeset
|
19 |
182
6c3a089d3265
Add test for str_base64_decode as i suspect it to have a bug
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
20 void CommonTest::testStrBase64Decode() { |
6c3a089d3265
Add test for str_base64_decode as i suspect it to have a bug
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
21 char garbage[1000]; |
6c3a089d3265
Add test for str_base64_decode as i suspect it to have a bug
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
22 char *data = NULL; |
6c3a089d3265
Add test for str_base64_decode as i suspect it to have a bug
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
23 size_t data_size = 0; |
6c3a089d3265
Add test for str_base64_decode as i suspect it to have a bug
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
24 int ret; |
6c3a089d3265
Add test for str_base64_decode as i suspect it to have a bug
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
25 for (int i = 0; i < 1000; i++) { |
6c3a089d3265
Add test for str_base64_decode as i suspect it to have a bug
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
26 garbage[i] = (char) qrand() % 255; |
6c3a089d3265
Add test for str_base64_decode as i suspect it to have a bug
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
27 } |
6c3a089d3265
Add test for str_base64_decode as i suspect it to have a bug
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
28 |
6c3a089d3265
Add test for str_base64_decode as i suspect it to have a bug
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
29 QByteArray ba(garbage, 1000); |
6c3a089d3265
Add test for str_base64_decode as i suspect it to have a bug
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
30 |
6c3a089d3265
Add test for str_base64_decode as i suspect it to have a bug
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
31 QByteArray baB64 = ba.toBase64(); |
6c3a089d3265
Add test for str_base64_decode as i suspect it to have a bug
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
32 |
6c3a089d3265
Add test for str_base64_decode as i suspect it to have a bug
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
33 ret = str_base64_decode(&data, &data_size, (char *)baB64.constData(), baB64.size()); |
6c3a089d3265
Add test for str_base64_decode as i suspect it to have a bug
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
34 |
6c3a089d3265
Add test for str_base64_decode as i suspect it to have a bug
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
35 QVERIFY(ret == 0); |
6c3a089d3265
Add test for str_base64_decode as i suspect it to have a bug
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
36 QVERIFY(data_size == 1000); |
184
1f44aae4528e
Add C linkage for strhelp. Check for data in commontest.
Andre Heinecke <aheinecke@intevation.de>
parents:
182
diff
changeset
|
37 QVERIFY(data); |
182
6c3a089d3265
Add test for str_base64_decode as i suspect it to have a bug
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
38 |
6c3a089d3265
Add test for str_base64_decode as i suspect it to have a bug
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
39 for (size_t i = 0; i < data_size; i++) { |
6c3a089d3265
Add test for str_base64_decode as i suspect it to have a bug
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
40 QVERIFY(garbage[i] == data[i]); |
6c3a089d3265
Add test for str_base64_decode as i suspect it to have a bug
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
41 } |
6c3a089d3265
Add test for str_base64_decode as i suspect it to have a bug
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
42 free (data); |
6c3a089d3265
Add test for str_base64_decode as i suspect it to have a bug
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
43 } |
6c3a089d3265
Add test for str_base64_decode as i suspect it to have a bug
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
44 |
6c3a089d3265
Add test for str_base64_decode as i suspect it to have a bug
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
45 QTEST_GUILESS_MAIN (CommonTest); |