0
Iは、ハッシュメッセージ<count:mac-addr>
を作成し、署名を生成するCにおけるサンプル署名発生器を有します。RSA_signとRSA_verify変化挙動
私はchar *message = "120:08:00:27:7c:b6:18";
や記号を使用すると、署名が正常に検証されます。
しかし、私は両方のケースで署名を生成するために、次の関数呼び出しを使用しています、
char* message;
message = generate_hash();
を確認しながら、私は---
char * generate_hash()
{
xmlDoc *document;
xmlNode *root, *first_child, *node;
char *filename;
char *ap_count;
char *ap_mac_address;
char *message;
filename = "/license.xml";
document = xmlReadFile(filename, NULL, 0);
root = xmlDocGetRootElement(document);
first_child = root->children;
for (node = first_child; node; node = node->next) {
if (strcmp((char*)node->name, "ap_count") == 0) {
ap_count = (char*)xmlNodeGetContent(node);
}
if (strcmp((char*)node->name, "ap_mac_address") == 0){
ap_mac_address = (char*)xmlNodeGetContent(node);
}
}
message = (char *) malloc(strlen(ap_count)+ strlen(ap_mac_address) +1);
memset(message,0x0,(1 + strlen(ap_count)+ strlen(ap_mac_address)));
strcpy(message,ap_count);
strcat(message,":");
strcat(message,ap_mac_address);
printf(" %d \n", (1 + strlen(ap_count)+ strlen(ap_mac_address)));
return message;
}
を使用しています。
if(RSA_sign(NID_sha256, (unsigned char*) message, strlen(message),
signature, &slen, private_key) != 1) {
ERR_print_errors_fp(stdout);
return 1;
}
上記の手順で署名検証が失敗します。私がここで間違っていることを確かめない。以下は
は、私は同じことを確認するために使用しています呼び出しです。
verified = RSA_verify(NID_sha256, (unsigned char*) message,
strlen(message), sign, file_len, public_key);