*
*/
+/* Until the key-gen callbacks are modified to use newer prototypes, we allow
+ * deprecated functions for openssl-internal code */
+#ifdef OPENSSL_NO_DEPRECATED
+#undef OPENSSL_NO_DEPRECATED
+#endif
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <openssl/opensslconf.h> /* To see if OPENSSL_NO_ECDSA is defined */
+
#ifdef OPENSSL_NO_ECDSA
int main(int argc, char * argv[])
{
#include <openssl/ecdsa.h>
#include <openssl/engine.h>
#include <openssl/err.h>
+#include <openssl/rand.h>
static const char rnd_seed[] = "string to make the random number generator "
"think it has entropy";
fake_rand.status = old_rand->status;
/* use own random function */
fake_rand.bytes = fbytes;
- fake_rand.pseudorand = fbytes;
+ fake_rand.pseudorand = old_rand->bytes;
/* set new RAND_METHOD */
if (!RAND_set_rand_method(&fake_rand))
return 0;
size_t crv_len = 0, n = 0;
EC_KEY *eckey = NULL, *wrong_eckey = NULL;
unsigned char digest[20], wrong_digest[20];
- unsigned char *signature;
+ unsigned char *signature = NULL;
unsigned int sig_len;
int nid, ret = 0;
/* now create and verify a signature for every curve */
for (n = 0; n < crv_len; n++)
{
+ unsigned char dirt, offset;
+
nid = curves[n].nid;
+ if (nid == NID_ipsec4)
+ continue;
/* create new ecdsa key (== EC_KEY) */
if ((eckey = EC_KEY_new()) == NULL)
goto builtin_err;
}
BIO_printf(out, ".");
BIO_flush(out);
- /* modify signature */
- signature[((int)signature[0])%sig_len] ^=
- signature[((int)signature[1])%sig_len];
+ /* modify a single byte of the signature */
+ offset = signature[10] % sig_len;
+ dirt = signature[11];
+ signature[offset] ^= dirt ? dirt : 1;
if (ECDSA_verify(0, digest, 20, signature, sig_len, eckey) == 1)
{
BIO_printf(out, " failed\n");
int main(void)
{
- int ret = 0;
+ int ret = 1;
BIO *out;
out = BIO_new_fp(stdout, BIO_NOCLOSE);
if (!x9_62_tests(out)) goto err;
if (!test_builtin(out)) goto err;
- ret = 1;
+ ret = 0;
err:
- if (!ret)
+ if (ret)
BIO_printf(out, "\nECDSA test failed\n");
else
BIO_printf(out, "\nECDSA test passed\n");
CRYPTO_mem_leaks(out);
if (out != NULL)
BIO_free(out);
- return(0);
+ return ret;
}
#endif