Skip to content

Commit a89d15e

Browse files
authored
Fixed #155 (#156)
* Fixed #155
1 parent 9713ccb commit a89d15e

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

services/crypto/crypto.c

+6-3
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@
66
#include "memset_s.h"
77

88
#define CRYPTO_KEY_SLOT (2)
9-
#define CRYPTO_VERIFY_KEY "FFF_Crypto_pass"
109
#define CRYPTO_VERIFY_KEY_LENGTH (16)
1110
#define CRYPTO_ALIGNMENT_FACTOR (16)
1211

12+
static const char* CRYPTO_VERIFY_KEY = "FFF_Crypto_pass";
13+
1314
uint8_t* totp_crypto_encrypt(
1415
const uint8_t* plain_data,
1516
const size_t plain_data_length,
@@ -104,7 +105,7 @@ CryptoSeedIVResult
104105
plugin_state->crypto_verify_data_length = CRYPTO_VERIFY_KEY_LENGTH;
105106

106107
plugin_state->crypto_verify_data = totp_crypto_encrypt(
107-
(uint8_t*)CRYPTO_VERIFY_KEY,
108+
(const uint8_t*)CRYPTO_VERIFY_KEY,
108109
CRYPTO_VERIFY_KEY_LENGTH,
109110
&plugin_state->iv[0],
110111
&plugin_state->crypto_verify_data_length);
@@ -119,7 +120,7 @@ CryptoSeedIVResult
119120

120121
bool totp_crypto_verify_key(const PluginState* plugin_state) {
121122
size_t decrypted_key_length;
122-
const uint8_t* decrypted_key = totp_crypto_decrypt(
123+
uint8_t* decrypted_key = totp_crypto_decrypt(
123124
plugin_state->crypto_verify_data,
124125
plugin_state->crypto_verify_data_length,
125126
&plugin_state->iv[0],
@@ -130,5 +131,7 @@ bool totp_crypto_verify_key(const PluginState* plugin_state) {
130131
if(decrypted_key[i] != CRYPTO_VERIFY_KEY[i]) key_valid = false;
131132
}
132133

134+
free(decrypted_key);
135+
133136
return key_valid;
134137
}

0 commit comments

Comments
 (0)