Skip to content

Commit

Permalink
export KeyRSA and KeyEd25519
Browse files Browse the repository at this point in the history
  • Loading branch information
tomis007 committed Dec 23, 2024
1 parent 2fae465 commit 303c195
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions v2/piv/key.go
Original file line number Diff line number Diff line change
Expand Up @@ -1001,9 +1001,9 @@ func (yk *YubiKey) PrivateKey(slot Slot, public crypto.PublicKey, auth KeyAuth)
case *ecdsa.PublicKey:
return &ECDSAPrivateKey{yk, slot, pub, auth, pp}, nil
case ed25519.PublicKey:
return &keyEd25519{yk, slot, pub, auth, pp}, nil
return &KeyEd25519{yk, slot, pub, auth, pp}, nil
case *rsa.PublicKey:
return &keyRSA{yk, slot, pub, auth, pp}, nil
return &KeyRSA{yk, slot, pub, auth, pp}, nil
case *ecdh.PublicKey:
if crv := pub.Curve(); crv != ecdh.X25519() {
return nil, fmt.Errorf("unsupported ecdh curve: %v", crv)
Expand Down Expand Up @@ -1283,43 +1283,43 @@ func (k *X25519PrivateKey) ECDH(peer *ecdh.PublicKey) ([]byte, error) {
})
}

type keyEd25519 struct {
type KeyEd25519 struct {
yk *YubiKey
slot Slot
pub ed25519.PublicKey
auth KeyAuth
pp PINPolicy
}

func (k *keyEd25519) Public() crypto.PublicKey {
func (k *KeyEd25519) Public() crypto.PublicKey {
return k.pub
}

func (k *keyEd25519) Sign(rand io.Reader, message []byte, opts crypto.SignerOpts) ([]byte, error) {
func (k *KeyEd25519) Sign(rand io.Reader, message []byte, opts crypto.SignerOpts) ([]byte, error) {
return k.auth.do(k.yk, k.pp, func(tx *scTx) ([]byte, error) {
return ykSignEd25519(tx, k.slot, k.pub, message, opts)
})
}

type keyRSA struct {
type KeyRSA struct {
yk *YubiKey
slot Slot
pub *rsa.PublicKey
auth KeyAuth
pp PINPolicy
}

func (k *keyRSA) Public() crypto.PublicKey {
func (k *KeyRSA) Public() crypto.PublicKey {
return k.pub
}

func (k *keyRSA) Sign(rand io.Reader, digest []byte, opts crypto.SignerOpts) ([]byte, error) {
func (k *KeyRSA) Sign(rand io.Reader, digest []byte, opts crypto.SignerOpts) ([]byte, error) {
return k.auth.do(k.yk, k.pp, func(tx *scTx) ([]byte, error) {
return ykSignRSA(tx, rand, k.slot, k.pub, digest, opts)
})
}

func (k *keyRSA) Decrypt(rand io.Reader, msg []byte, opts crypto.DecrypterOpts) ([]byte, error) {
func (k *KeyRSA) Decrypt(rand io.Reader, msg []byte, opts crypto.DecrypterOpts) ([]byte, error) {
return k.auth.do(k.yk, k.pp, func(tx *scTx) ([]byte, error) {
return ykDecryptRSA(tx, k.slot, k.pub, msg)
})
Expand Down

0 comments on commit 303c195

Please sign in to comment.