update go api

This commit is contained in:
Zhi Guan
2017-05-20 09:04:46 +08:00
parent cb44612ccd
commit 2299b8ff22
4 changed files with 148 additions and 10 deletions

View File

@@ -10,12 +10,27 @@ import (
"errors"
)
/*
int PKCS5_PBKDF2_HMAC(const char *pass, int passlen,
const unsigned char *salt, int saltlen, int iter,
const EVP_MD *digest, int keylen, unsigned char *out);
int EVP_PBE_scrypt(const char *pass, size_t passlen,
const unsigned char *salt, size_t saltlen,
uint64_t N, uint64_t r, uint64_t p, uint64_t maxmem,
unsigned char *key, size_t keylen);
*/
func GetKeyDeriveFunctions(aliases bool) []string {
return []string{"PBKDF2v1", "PBKDFv2", "scrypt"}
return []string{"PBKDF", "PBKDF2", "scrypt"}
}
func DeriveKeyFromPassword(scheme string, args map[string]string, password string, salt []byte) ([]byte, error) {
return nil, errors.New("Not implemented")
func DeriveKeyFromPassword(algor string, args map[string]string, password string, salt []byte, keylen int) ([]byte, error) {
if algor == "PBKDF2" {
if 1 != PKCS5_PBKDF2_HMAC(pass, passlen, salt, saltlen, iter, md, keylen, out) {
}
else if algor == "scrypt" {
if 1 != gmssl_scrypt()
} else {
return nil, errors.New("Not implemented")
}
}