-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathrandom.go
56 lines (50 loc) · 1.54 KB
/
random.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/* random.go
*
* Copyright (C) 2006-2022 wolfSSL Inc.
*
* This file is part of wolfSSL.
*
* wolfSSL is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* wolfSSL is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
*/
package wolfSSL
// #include <wolfssl/options.h>
// #include <wolfssl/wolfcrypt/random.h>
// #ifdef WC_NO_RNG
// typedef struct WC_RNG {} WC_RNG;
// int wc_InitRng(WC_RNG* rng) {
// return -174;
// }
// int wc_FreeRng(WC_RNG* rng) {
// return -174;
// }
// int wc_RNG_GenerateBlock(WC_RNG* rng, byte* b, word32 sz) {
// return -174;
// }
// #endif
import "C"
import (
"unsafe"
)
type WC_RNG = C.struct_WC_RNG
func Wc_InitRng(rng *C.struct_WC_RNG) int {
return int(C.wc_InitRng(rng))
}
func Wc_FreeRng(rng *C.struct_WC_RNG) int {
return int(C.wc_FreeRng(rng))
}
func Wc_RNG_GenerateBlock(rng *C.struct_WC_RNG, b []byte, sz int) int {
return int(C.wc_RNG_GenerateBlock(rng, (*C.uchar)(unsafe.Pointer(&b[0])),
C.word32(sz)))
}