Added a (small) usage howto about the openssl_act engine, based on the PoC sources, see #6
This commit is contained in:
75
openssl-act-engine/USING_ENGINE_act.txt
Normal file
75
openssl-act-engine/USING_ENGINE_act.txt
Normal file
@@ -0,0 +1,75 @@
|
||||
Benutzung der engine_act OpenSSL engine
|
||||
|
||||
Abgesehen von den Engine-Befehlen "ENUM_CERTS" und "PIN" (s.u.) l<>uft die Benutzung dieser Engine <20>ber OpenSSL selbst ab.
|
||||
|
||||
1) Laden/Einbinden
|
||||
|
||||
SO_PATH gibt den absoluten Pfad zur Engine an.
|
||||
|
||||
#include <openssl/engine.h>
|
||||
|
||||
ENGINE *e;
|
||||
|
||||
ENGINE_load_dynamic();
|
||||
e = ENGINE_by_id("dynamic");
|
||||
|
||||
int r= ENGINE_ctrl_cmd_string(e, "SO_PATH", "C:\\Windows\\System32\\engine_act.dll", 0);
|
||||
r= ENGINE_ctrl_cmd_string(e, "ID", "act", 0);
|
||||
r= ENGINE_ctrl_cmd_string(e, "LIST_ADD", "1", 0);
|
||||
r= ENGINE_ctrl_cmd_string(e, "LOAD", NULL, 0);
|
||||
|
||||
2) Entfernen der Engine und abschliessende Operationen
|
||||
|
||||
ENGINE_finish(e);
|
||||
ENGINE_cleanup();
|
||||
|
||||
|
||||
3) Enumerierung der erreichbaren Smartcard-Zertifikate und Schl<68>ssel
|
||||
|
||||
#include <openssl/engine.h>
|
||||
#include "engine_sct.h"
|
||||
|
||||
enum_certs_s* certs_found = NULL;
|
||||
|
||||
int r = ENGINE_ctrl_cmd(e, "ENUM_CERTS", 0, &certs_found, NULL, 0);
|
||||
|
||||
|
||||
enum_certs_s ist eine Struktur von der folgenden Form:
|
||||
|
||||
struct enum_cert_s
|
||||
{
|
||||
const char* id; // ID which can be passed as key ID for crypto operations
|
||||
const char* name; // Alternatively one can use the name, provided it's unique for the token.
|
||||
X509* cert; // Decoded certificate
|
||||
};
|
||||
|
||||
struct enum_certs_s
|
||||
{
|
||||
unsigned int num_certs; // Number of certificates present
|
||||
enum_cert_s certificate[]; // Array of identifiers and certificates
|
||||
};
|
||||
|
||||
|
||||
So kann man dann mit einer for-Schleife <20>ber die einzelnen Zertifikate/Schl<68>sselidentifikationen iterieren
|
||||
|
||||
for(int i=0;i<certs_found->num_certs;i++)
|
||||
{
|
||||
enum_cert_s* cert_data = &(certs_found->certificate[i]);
|
||||
|
||||
....
|
||||
}
|
||||
|
||||
4) Laden eines Schl<68>ssels zur Benutzung
|
||||
|
||||
Sowohl cert_data.id als auch cert_data.name k<>nnen als Parameter f<>r ENGINE_load_public_key() oder ENGINE_load_private_key() verwendet werden.
|
||||
cert_data.name hat das Format "slot-<x>-name-<name>", der Authenthisierungsschl<68>ssel im ersten (oder einzigen) Slot w<>re dann
|
||||
|
||||
"slot-0-name-SwissSign_digSig"
|
||||
|
||||
ENGINE_load_private_key() versucht gleich schon ein Login auf der Karte. Man kann ein Pin-Dialog per Callback <20>bergeben, aber man kann auch
|
||||
die PIN von vornherein setzen, und zwar mit
|
||||
|
||||
ENGINE_ctrl_cmd_string(e, "PIN", pin_str, 0);
|
||||
|
||||
/!\ pin_str ist ein nullterminierter String (char *) und wird in der Funktion <20>berschrieben! Wird die PIN also sp<73>ter anderswo noch gebraucht, muss man
|
||||
hier eine Kopie des Strings <20>bergeben.
|
Reference in New Issue
Block a user