some minor changes; refs #8
This commit is contained in:
@@ -62,9 +62,10 @@ int main(int argc, char* argv[])
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
EVP_PKEY* pk_pub = ENGINE_load_public_key(e, selected_cert->id, NULL, NULL);
|
||||
RSA* pubkey = EVP_PKEY_get1_RSA(pk_pub);
|
||||
|
||||
|
||||
const char* source = "Dies ist ein geheimer Testtext zum Verschlüsseln\n";
|
||||
int srclen = strlen(source)+1;
|
||||
|
||||
@@ -82,13 +83,33 @@ int main(int argc, char* argv[])
|
||||
|
||||
EVP_PKEY_free(pk_priv);
|
||||
RSA_free(privkey);
|
||||
|
||||
|
||||
if(srclen != plainlen || strcmp(source, plainbuf))
|
||||
printf("Unterschied in Ver/Entschlüsselung");
|
||||
else
|
||||
printf("%s",plainbuf);
|
||||
|
||||
|
||||
|
||||
*/
|
||||
|
||||
const char *source = "Dies ist ein Testtext zum Signieren.\n";
|
||||
int srclen = strlen(source)+1;
|
||||
|
||||
char signature[1000];
|
||||
unsigned int siglen = 0;
|
||||
|
||||
EVP_PKEY* pk_priv = ENGINE_load_private_key(e, selected_cert->id, NULL, NULL);
|
||||
RSA* privkey = EVP_PKEY_get1_RSA(pk_priv);
|
||||
|
||||
|
||||
CHECK(RSA_sign(NID_md5_sha1, (const unsigned char*)source, srclen, (unsigned char*)signature, &siglen, privkey));
|
||||
printf("Signature-Len: %d\n", siglen);
|
||||
|
||||
EVP_PKEY* pk_pub = ENGINE_load_public_key(e, selected_cert->id, NULL, NULL);
|
||||
RSA* pubkey = EVP_PKEY_get1_RSA(pk_pub);
|
||||
|
||||
CHECK(RSA_verify(NID_md5_sha1,(const unsigned char*) source, srclen, (unsigned char*)signature, siglen, pubkey));
|
||||
|
||||
|
||||
|
||||
CHECK(ENGINE_finish(e));
|
||||
|
Reference in New Issue
Block a user