mirror of
https://github.com/guanzhi/GmSSL.git
synced 2026-08-09 07:23:56 +08:00
update go api
This commit is contained in:
@@ -1,2 +1,20 @@
|
|||||||
/* +build cgo */
|
/* +build cgo */
|
||||||
package gmssl
|
package gmssl
|
||||||
|
|
||||||
|
/*
|
||||||
|
#include <openssl/x509.h>
|
||||||
|
#include <openssl/pem.h>
|
||||||
|
*/
|
||||||
|
import "C"
|
||||||
|
|
||||||
|
import (
|
||||||
|
"errors"
|
||||||
|
)
|
||||||
|
|
||||||
|
func GetAttributesFromCertificate(cert string) (map[string]string, error) {
|
||||||
|
return nil, errors.New("Not implemented")
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetPublicKeyFromCertificate(cert string) (*PublicKey, error) {
|
||||||
|
return nil, errors.New("Not implemented")
|
||||||
|
}
|
||||||
|
|||||||
37
go/engine.go
37
go/engine.go
@@ -1,2 +1,39 @@
|
|||||||
/* +build cgo */
|
/* +build cgo */
|
||||||
package gmssl
|
package gmssl
|
||||||
|
|
||||||
|
/*
|
||||||
|
#include <openssl/engine.h>
|
||||||
|
*/
|
||||||
|
import "C"
|
||||||
|
|
||||||
|
import (
|
||||||
|
"errors"
|
||||||
|
)
|
||||||
|
|
||||||
|
func GetEngineNames() []string {
|
||||||
|
return []string{"skf", "sdf"}
|
||||||
|
}
|
||||||
|
|
||||||
|
type Engine struct {
|
||||||
|
engine *C.ENGINE
|
||||||
|
}
|
||||||
|
|
||||||
|
func OpenEngine(name string, args map[string]string) (*Engine, error) {
|
||||||
|
return nil, errors.New("Not implemented")
|
||||||
|
}
|
||||||
|
|
||||||
|
func (eng *Engine) ExecuteCommand(cmd_name string, arg string, optinal bool) (string, error) {
|
||||||
|
return "", errors.New("Not implemented")
|
||||||
|
}
|
||||||
|
|
||||||
|
func (eng *Engine) LoadPrivateKey(key_id string, args map[string]string) (*PrivateKey, error) {
|
||||||
|
return nil, errors.New("Not implemented")
|
||||||
|
}
|
||||||
|
|
||||||
|
func (eng *Engine) LoadPublicKey(key_id string, args map[string]string) (*PublicKey, error) {
|
||||||
|
return nil, errors.New("Not implemented")
|
||||||
|
}
|
||||||
|
|
||||||
|
func (eng *Engine) LoadCertificate(ca_dn []string, args map[string]string) (string, error) {
|
||||||
|
return "", errors.New("Not implemented")
|
||||||
|
}
|
||||||
|
|||||||
21
go/pbkdf.go
Normal file
21
go/pbkdf.go
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
/* +build cgo */
|
||||||
|
package gmssl
|
||||||
|
|
||||||
|
/*
|
||||||
|
#include <openssl/evp.h>
|
||||||
|
*/
|
||||||
|
import "C"
|
||||||
|
|
||||||
|
import (
|
||||||
|
"errors"
|
||||||
|
)
|
||||||
|
|
||||||
|
func GetKeyDeriveFunctions(aliases bool) []string {
|
||||||
|
return []string{"PBKDF2v1", "PBKDFv2", "scrypt"}
|
||||||
|
}
|
||||||
|
|
||||||
|
func DeriveKeyFromPassword(scheme string, args map[string]string, password string, salt []byte) ([]byte, error) {
|
||||||
|
return nil, errors.New("Not implemented")
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
15
go/pkey.go
15
go/pkey.go
@@ -130,5 +130,20 @@ func (pkey *PublicKey) Verify(scheme string, args map[string]string, data, signa
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (pkey *PrivateKey) DeriveKey(scheme string, args map[string]string, publicKey PublicKey) ([]byte, error) {
|
func (pkey *PrivateKey) DeriveKey(scheme string, args map[string]string, publicKey PublicKey) ([]byte, error) {
|
||||||
|
ctx := C.EVP_PKEY_CTX_new(pkey.pkey, nil)
|
||||||
|
if ctx == nil {
|
||||||
|
return nil, errors.New("Failure")
|
||||||
|
}
|
||||||
|
if 1 != C.EVP_PKEY_derive_init(ctx) {
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
if 1 != C.EVP_PKEY_derive_set_peer(ctx, PublicKey.pkey) {
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
outbuf := make([]byte, C.EVP_PKEY_size(pkey.pkey))
|
||||||
|
outlen := C.size_t(len(outbuf))
|
||||||
|
if 1 != C.EVP_PKEY_derive(ctx, (*C.uchar)(&outbuf[0]), &outlen) {
|
||||||
|
}
|
||||||
return nil, errors.New("Not implemented")
|
return nil, errors.New("Not implemented")
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user