mirror of
https://github.com/paralus/paralus.git
synced 2026-05-13 03:47:08 +00:00
* restructure rcloud-base as a single base controller * updated master.rest * moved sentry from internal to pkg as it is used by relay * removing unused rpc and it's dependencies * Fix usermgmt tests * Don't redefine variables in rest file Co-authored-by: Abin Simon <abin.simon@rafay.co>
37 lines
519 B
Go
37 lines
519 B
Go
package cryptoutil
|
|
|
|
import (
|
|
"reflect"
|
|
"testing"
|
|
)
|
|
|
|
func TestEncryptDecryptPrivateKey(t *testing.T) {
|
|
privKey, err := GenerateECDSAPrivateKey()
|
|
|
|
if err != nil {
|
|
t.Error(err)
|
|
return
|
|
}
|
|
|
|
pf := func() ([]byte, error) {
|
|
return []byte(`pass123`), nil
|
|
}
|
|
|
|
enc, err := EncodePrivateKey(privKey, pf)
|
|
if err != nil {
|
|
t.Error(err)
|
|
return
|
|
}
|
|
|
|
privKey1, err := DecodePrivateKey(enc, pf)
|
|
if err != nil {
|
|
t.Error(err)
|
|
return
|
|
}
|
|
|
|
if !reflect.DeepEqual(privKey1, privKey) {
|
|
t.Error("expected same key")
|
|
}
|
|
|
|
}
|