Fixes

parent 6223b8f3
......@@ -52,7 +52,7 @@ enclave {
public void ecdsa_sign_message (
[user_check] int *err_status,
[out, count = 1024] char* err_string,
[in, count = 1024] unsigned char* encrypted_key,
[in, count = 1024] uint8_t* encrypted_key,
uint32_t enc_len,
[in, count = 1024] uint8_t* hash,
[out, count = 1024] char* signature);
......
......@@ -185,61 +185,21 @@ TEST_CASE("BLS sign test", "[bls-sign]") {
init_all();
const char *key = "4160780231445160889237664391382223604184857153814275770598"
"791864649971919844";
char* encryptedKeyHex = encryptTestKey();
REQUIRE(encryptedKeyHex != nullptr);
const char *hexHash = "001122334455667788" "001122334455667788" "001122334455667788" "001122334455667788";
char *keyArray = (char *) calloc(128, 1);
uint8_t *encryptedKey = (uint8_t *) calloc(1024, 1);
char *errMsg = (char *) calloc(1024, 1);
strncpy((char *) keyArray, (char *) key, 128);
int errStatus = 0;
unsigned int encryptedLen = 0;
status = encrypt_key(eid, &errStatus, errMsg, keyArray, encryptedKey, &encryptedLen);
REQUIRE(status == SGX_SUCCESS);
REQUIRE(errStatus == 0);
printf("Encrypt key completed with status: %d %s \n", errStatus, errMsg);
printf(" Encrypted key len %d\n", encryptedLen);
char result[2 * BUF_LEN];
carray2Hex(encryptedKey, encryptedLen, result
);
uint64_t dec_len = 0;
uint8_t bin[BUF_LEN];
REQUIRE(hex2carray(result, &dec_len, bin)
);
for (uint64_t i = 0; i < dec_len; i++) {
REQUIRE(bin[i] == encryptedKey[i]);
}
REQUIRE(dec_len == encryptedLen);
const char *hexHash = "001122334455667788" "001122334455667788" "001122334455667788" "001122334455667788";
gmp_printf("Result: %s", result);
char* hexHashBuf = (char*) calloc(BUF_LEN, 1);
gmp_printf("\n Length: %d \n", encryptedLen);
strncpy(hexHashBuf, hexHash, BUF_LEN);
char sig[BUF_LEN];
REQUIRE(sign(result, hexHash, 2, 2, 1, sig));
REQUIRE(sign(encryptedKeyHex, hexHashBuf, 2, 2, 1, sig));
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment