Bladeren bron

fix: gmssl,随机数函数的适配,依然需要中转一下,因为返回值的定义不同

Wendal Chen 5 maanden geleden
bovenliggende
commit
f6bf7270b6
2 gewijzigde bestanden met toevoegingen van 25 en 3 verwijderingen
  1. 2 3
      components/gmssl/include/gmssl/rand.h
  2. 23 0
      components/gmssl/src/rand.c

+ 2 - 3
components/gmssl/include/gmssl/rand.h

@@ -25,9 +25,8 @@ Rand Public API
 	rand_bytes
 
 */
-extern int luat_crypto_trng(char* buff, size_t len);
-#define rand_bytes(x, y) luat_crypto_trng((char*)x, y)
-// _gmssl_export int rand_bytes(uint8_t *buf, size_t buflen);
+extern int luat_gmssl_rand_bytes(uint8_t *buf, size_t len);
+#define rand_bytes luat_gmssl_rand_bytes
 
 
 #ifdef __cplusplus

+ 23 - 0
components/gmssl/src/rand.c

@@ -0,0 +1,23 @@
+/*
+ *  Copyright 2014-2022 The GmSSL Project. All Rights Reserved.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the License); you may
+ *  not use this file except in compliance with the License.
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ */
+
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <gmssl/rand.h>
+#include <gmssl/error.h>
+
+extern int luat_crypto_trng(char* buff, size_t len);
+
+int luat_gmssl_rand_bytes(uint8_t *buf, size_t len)
+{
+	luat_crypto_trng((char*)buf, len);
+	return 1;
+}