use XFILE, BADFILE, XFxxxx

This commit is contained in:
Takashi Kojo
2018-07-04 06:52:22 +09:00
committed by Go Hosohara
parent 787fa5d49a
commit e6612b34f7
10 changed files with 236 additions and 214 deletions

View File

@@ -207,15 +207,16 @@ RsaKey* GetRsaPrivateKey(const char* keyFile)
size_t bytes;
int ret;
word32 idx = 0;
FILE* file = fopen(keyFile, "rb");
XFILE file = XFOPEN(keyFile, "rb");
if (!file) {
if (file != XBADFILE)
{
free(key);
return 0;
}
bytes = fread(tmp, 1, sizeof(tmp), file);
fclose(file);
bytes = XFREAD(tmp, 1, sizeof(tmp), file);
XFCLOSE(file);
wc_InitRsaKey(key, 0);
ret = wc_RsaPrivateKeyDecode(tmp, &idx, key, (word32)bytes);