Skip to content

Commit

Permalink
add methods to get master public key
Browse files Browse the repository at this point in the history
  • Loading branch information
opensvn committed Jun 16, 2022
1 parent 5c6c980 commit ca87062
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
8 changes: 8 additions & 0 deletions kgc.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,18 @@ func New() *Kgc {
}
}

func (k *Kgc) GetSignMasterPublicKey() *sm9.SignMasterPublicKey {
return k.signMasterKey.Public()
}

func (k *Kgc) GenerateUserSignKey(uid []byte, hid byte) (*sm9.SignPrivateKey, error) {
return k.signMasterKey.GenerateUserKey(uid, hid)
}

func (k *Kgc) GetEncryptMasterPublicKey() *sm9.EncryptMasterPublicKey {
return k.encryptMasterKey.Public()
}

func (k *Kgc) GenerateUserEncryptKey(uid []byte, hid byte) (*sm9.EncryptPrivateKey, error) {
return k.encryptMasterKey.GenerateUserKey(uid, hid)
}
24 changes: 24 additions & 0 deletions kgc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,18 @@ func TestNewKgc(t *testing.T) {
}
}

func TestGetSignMasterPublicKey(t *testing.T) {
kgc := New()
if kgc == nil {
t.Error("kgc is nil")
}

signMasterPublicKey := kgc.GetSignMasterPublicKey()
if signMasterPublicKey == nil {
t.Error("signMasterPublicKey is nil")
}
}

func TestGenerateUserSignKey(t *testing.T) {
kgc := New()
if kgc == nil {
Expand All @@ -35,6 +47,18 @@ func TestGenerateUserSignKey(t *testing.T) {
}
}

func TestGetEncryptMasterPublicKey(t *testing.T) {
kgc := New()
if kgc == nil {
t.Error("kgc is nil")
}

encryptMasterPublicKey := kgc.GetEncryptMasterPublicKey()
if encryptMasterPublicKey == nil {
t.Error("signMasterPublicKey is nil")
}
}

func TestGenerateUserEncryptKey(t *testing.T) {
kgc := New()
if kgc == nil {
Expand Down

0 comments on commit ca87062

Please sign in to comment.