Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

PUBKEY Failed

Empfohlene Antworten

Veröffentlicht

Hallo,

Ich habe ein Programm ecdsa-Chifrierverfahren!

Der vom Code her compiliert und functioniert

nur die folgende Methode:

EVP_PKEY* pkey = PEM_read_bio_PUBKEY(mem,0,0,0); lierfert kein Wert zurück

deswegen bleibt pkey undefiniert und somit kommt es zum problem :

Unhandled Exception: System.AccessViolationException: Attempted to read or write protected memory. T.....

mein code sieht wie folgt aus:

#include "stdafx.h"

#include "string.h"

#include "openssl/evp.h"

#include "openssl/pem.h"

#include "openssl/sha.h"

#include "openssl/err.h"



int _tmain(int argc, _TCHAR* argv[])

{


	CRYPTO_malloc_init();

	OpenSSL_add_all_algorithms();

	unsigned char sha1sum[SHA_DIGEST_LENGTH];

	char* sig = "........................";

	char* data = "blabla bla";

	char* key = "keyyyyyyyyyyyyyyyyyyyy";


	// make hash of data

	SHA1((const unsigned char*)data, strlen(data), sha1sum);


	// load key

	BIO* b64 = BIO_new(BIO_f_base64());

	BIO* mem = BIO_new(BIO_s_mem());

	BIO_puts(mem,key);

	mem = BIO_push(b64,mem);

	[COLOR="red"]EVP_PKEY* pkey=PEM_read_bio_PUBKEY(mem,0,0,0);[/COLOR]

	if( pkey == 0){

	  //ERR_print_errors_fp(stdout);

		printf("Fehler");

	}

	EC_KEY* eckey = EVP_PKEY_get1_EC_KEY(pkey);


	// verify signature

	int ret = ECDSA_verify(0, sha1sum,SHA_DIGEST_LENGTH, (unsigned char*) sig, strlen(sig), eckey);

	if (ret == -1)

    {

        /* error */

    }

	else if (ret == 0)

    {

        /* incorrect signature */

    }

	else   /* ret == 1 */

    {

        /* signature ok */

    }

	return 0;

}

gibt es eine andere Methode in Opensource das funktionieren würde?

Danke

Kann niemand mir bitte helfen oder villeicht ein Forum vorschlagen die sich mit ECDSA auskennen?

OK, ne ist wirklich kein "keyyyyyy" ich habe es nur Geheimhaltungszwecken gemacht...

Naja die Daten und das Key aendert sich jedes mal, wenn es wichtig ist dann kann ich die auch angeben, mir geht es um den Prinzip, die Signatur überprüfung

ja, hier ist ein Bsp:

char* sig = "BIGACaAHmoSDLeLY6lILMbiw63ClZaUle9VLTdEv+h543qnQRxGENEv2vKrpE5gTzp40Exem72n0aHltHzOkdF03BKkhsmP6Kh9cUfgksa0pLPNeKIOLKL/iZM50TtATp/le37GOnPQRS6qbEq295xr95q0R5cruWVxaml5HI7QA6+E=";

char* data = ";\"4399901870215\";\"5701000536-02\";\"4311596435982\";\"20080829082706686\";";

char* key = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCXKToZE0gv4P/JmvcaUSPHHHY7dU4gw/no/dsYJ/QEKHvM95J+sAjoGp0L4COPHBdlPVVbjkfeZjfCVAL9zzlFu3gZIFbl7lrh5g43ieNs7R4mlWFJQWLmh/bwcdSHOBvBRO4dfSh9WfnNYQIjsnNh108P99nfInjZwQDTqX1FzwIDAQAB";

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.