MCPcopy Create free account
hub / github.com/GmSSL/GmSSL-Go / ExtractKey

Method ExtractKey

sm9.go:138–154  ·  view source on GitHub ↗
(id string)

Source from the content-addressed store, hash-verified

136}
137
138func (sm9 *Sm9EncMasterKey) ExtractKey(id string) (*Sm9EncKey, error) {
139 if sm9.has_private_key != true {
140 return nil, errors.New("Not private key")
141 }
142
143 id_str := C.CString(id)
144 defer C.free(unsafe.Pointer(id_str))
145
146 ret := new(Sm9EncKey)
147
148 if C.sm9_enc_master_key_extract_key(&sm9.master_key, id_str, C.strlen(id_str), &ret.key) != 1 {
149 return nil, errors.New("Libgmssl inner error")
150 }
151 ret.id = id
152
153 return ret, nil
154}
155
156func (sm9 *Sm9EncMasterKey) Encrypt(in []byte, to string) ([]byte, error) {
157

Callers 3

TestSm9EncFunction · 0.45
TestSm9SignFunction · 0.45
mainFunction · 0.45

Calls

no outgoing calls

Tested by 2

TestSm9EncFunction · 0.36
TestSm9SignFunction · 0.36