-
Notifications
You must be signed in to change notification settings - Fork 5
/
alg_factory.go
81 lines (59 loc) · 2.38 KB
/
alg_factory.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
package foundation
// #include <virgil/crypto/foundation/vscf_foundation_public.h>
import "C"
import "runtime"
import unsafe "unsafe"
/*
* Create algorithms based on the given information.
*/
type AlgFactory struct {
}
/*
* Create algorithm that implements "hash stream" interface.
*/
func AlgFactoryCreateHashFromInfo(algInfo AlgInfo) (Hash, error) {
proxyResult := /*pr4*/C.vscf_alg_factory_create_hash_from_info((*C.vscf_impl_t)(unsafe.Pointer(algInfo.Ctx())))
runtime.KeepAlive(algInfo)
return FoundationImplementationWrapHash(proxyResult) /* r4 */
}
/*
* Create algorithm that implements "mac stream" interface.
*/
func AlgFactoryCreateMacFromInfo(algInfo AlgInfo) (Mac, error) {
proxyResult := /*pr4*/C.vscf_alg_factory_create_mac_from_info((*C.vscf_impl_t)(unsafe.Pointer(algInfo.Ctx())))
runtime.KeepAlive(algInfo)
return FoundationImplementationWrapMac(proxyResult) /* r4 */
}
/*
* Create algorithm that implements "kdf" interface.
*/
func AlgFactoryCreateKdfFromInfo(algInfo AlgInfo) (Kdf, error) {
proxyResult := /*pr4*/C.vscf_alg_factory_create_kdf_from_info((*C.vscf_impl_t)(unsafe.Pointer(algInfo.Ctx())))
runtime.KeepAlive(algInfo)
return FoundationImplementationWrapKdf(proxyResult) /* r4 */
}
/*
* Create algorithm that implements "salted kdf" interface.
*/
func AlgFactoryCreateSaltedKdfFromInfo(algInfo AlgInfo) (SaltedKdf, error) {
proxyResult := /*pr4*/C.vscf_alg_factory_create_salted_kdf_from_info((*C.vscf_impl_t)(unsafe.Pointer(algInfo.Ctx())))
runtime.KeepAlive(algInfo)
return FoundationImplementationWrapSaltedKdf(proxyResult) /* r4 */
}
/*
* Create algorithm that implements "cipher" interface.
*/
func AlgFactoryCreateCipherFromInfo(algInfo AlgInfo) (Cipher, error) {
proxyResult := /*pr4*/C.vscf_alg_factory_create_cipher_from_info((*C.vscf_impl_t)(unsafe.Pointer(algInfo.Ctx())))
runtime.KeepAlive(algInfo)
return FoundationImplementationWrapCipher(proxyResult) /* r4 */
}
/*
* Create algorithm that implements "padding" interface.
*/
func AlgFactoryCreatePaddingFromInfo(algInfo AlgInfo, random Random) (Padding, error) {
proxyResult := /*pr4*/C.vscf_alg_factory_create_padding_from_info((*C.vscf_impl_t)(unsafe.Pointer(algInfo.Ctx())), (*C.vscf_impl_t)(unsafe.Pointer(random.Ctx())))
runtime.KeepAlive(algInfo)
runtime.KeepAlive(random)
return FoundationImplementationWrapPadding(proxyResult) /* r4 */
}