mirror of
https://github.com/go-i2p/go-i2p.git
synced 2025-06-08 10:32:04 -04:00
check in the stuff I have locally that I haven't yet, mostly ECDSA stuff which is not very useful
This commit is contained in:
@ -17,7 +17,7 @@ type (
|
|||||||
|
|
||||||
// Len implements types.SigningPrivateKey.
|
// Len implements types.SigningPrivateKey.
|
||||||
func (e *ECP256PrivateKey) Len() int {
|
func (e *ECP256PrivateKey) Len() int {
|
||||||
panic("unimplemented")
|
return 32
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sign implements types.Signer.
|
// Sign implements types.Signer.
|
||||||
|
@ -5,6 +5,7 @@ import (
|
|||||||
"crypto/elliptic"
|
"crypto/elliptic"
|
||||||
|
|
||||||
"github.com/go-i2p/go-i2p/lib/crypto/types"
|
"github.com/go-i2p/go-i2p/lib/crypto/types"
|
||||||
|
"github.com/samber/oops"
|
||||||
)
|
)
|
||||||
|
|
||||||
type (
|
type (
|
||||||
@ -13,17 +14,30 @@ type (
|
|||||||
|
|
||||||
// Verify implements types.Verifier.
|
// Verify implements types.Verifier.
|
||||||
func (k ECP256PublicKey) Verify(data []byte, sig []byte) error {
|
func (k ECP256PublicKey) Verify(data []byte, sig []byte) error {
|
||||||
panic("unimplemented")
|
log.WithField("data_length", len(data)).Debug("Verifying data with ECDSA-P256")
|
||||||
|
verifier, err := k.NewVerifier()
|
||||||
|
if err != nil {
|
||||||
|
log.WithError(err).Error("Failed to create verifier")
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return verifier.Verify(data, sig)
|
||||||
}
|
}
|
||||||
|
|
||||||
// VerifyHash implements types.Verifier.
|
// VerifyHash implements types.Verifier.
|
||||||
func (k ECP256PublicKey) VerifyHash(h []byte, sig []byte) error {
|
func (k ECP256PublicKey) VerifyHash(h []byte, sig []byte) error {
|
||||||
panic("unimplemented")
|
log.WithField("hash_length", len(h)).Debug("Verifying hash with ECDSA-P256")
|
||||||
|
verifier, err := k.NewVerifier()
|
||||||
|
if err != nil {
|
||||||
|
log.WithError(err).Error("Failed to create verifier")
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return verifier.VerifyHash(h, sig)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Encrypt implements types.Encrypter.
|
// Encrypt implements types.Encrypter.
|
||||||
func (k *ECP256PublicKey) Encrypt(data []byte) (enc []byte, err error) {
|
func (k *ECP256PublicKey) Encrypt(data []byte) (enc []byte, err error) {
|
||||||
panic("unimplemented")
|
log.Error("Encryption not supported with ECDSA keys")
|
||||||
|
return nil, oops.Errorf("encryption not supported with ECDSA keys; ECDSA is for signing/verification only")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (k ECP256PublicKey) Len() int {
|
func (k ECP256PublicKey) Len() int {
|
||||||
|
@ -13,12 +13,24 @@ type (
|
|||||||
|
|
||||||
// Verify implements types.Verifier.
|
// Verify implements types.Verifier.
|
||||||
func (k ECP384PublicKey) Verify(data []byte, sig []byte) error {
|
func (k ECP384PublicKey) Verify(data []byte, sig []byte) error {
|
||||||
panic("unimplemented")
|
log.WithField("data_length", len(data)).Debug("Verifying data with ECDSA-P384")
|
||||||
|
verifier, err := k.NewVerifier()
|
||||||
|
if err != nil {
|
||||||
|
log.WithError(err).Error("Failed to create verifier")
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return verifier.Verify(data, sig)
|
||||||
}
|
}
|
||||||
|
|
||||||
// VerifyHash implements types.Verifier.
|
// VerifyHash implements types.Verifier.
|
||||||
func (k ECP384PublicKey) VerifyHash(h []byte, sig []byte) error {
|
func (k ECP384PublicKey) VerifyHash(h []byte, sig []byte) error {
|
||||||
panic("unimplemented")
|
log.WithField("hash_length", len(h)).Debug("Verifying hash with ECDSA-P384")
|
||||||
|
verifier, err := k.NewVerifier()
|
||||||
|
if err != nil {
|
||||||
|
log.WithError(err).Error("Failed to create verifier")
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return verifier.VerifyHash(h, sig)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (k ECP384PublicKey) Bytes() []byte {
|
func (k ECP384PublicKey) Bytes() []byte {
|
||||||
|
@ -13,12 +13,24 @@ type (
|
|||||||
|
|
||||||
// Verify implements types.Verifier.
|
// Verify implements types.Verifier.
|
||||||
func (k ECP521PublicKey) Verify(data []byte, sig []byte) error {
|
func (k ECP521PublicKey) Verify(data []byte, sig []byte) error {
|
||||||
panic("unimplemented")
|
log.WithField("data_length", len(data)).Debug("Verifying data with ECDSA-P521")
|
||||||
|
verifier, err := k.NewVerifier()
|
||||||
|
if err != nil {
|
||||||
|
log.WithError(err).Error("Failed to create verifier")
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return verifier.Verify(data, sig)
|
||||||
}
|
}
|
||||||
|
|
||||||
// VerifyHash implements types.Verifier.
|
// VerifyHash implements types.Verifier.
|
||||||
func (k ECP521PublicKey) VerifyHash(h []byte, sig []byte) error {
|
func (k ECP521PublicKey) VerifyHash(h []byte, sig []byte) error {
|
||||||
panic("unimplemented")
|
log.WithField("hash_length", len(h)).Debug("Verifying hash with ECDSA-P521")
|
||||||
|
verifier, err := k.NewVerifier()
|
||||||
|
if err != nil {
|
||||||
|
log.WithError(err).Error("Failed to create verifier")
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return verifier.VerifyHash(h, sig)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (k ECP521PublicKey) Bytes() []byte {
|
func (k ECP521PublicKey) Bytes() []byte {
|
||||||
|
@ -11,3 +11,5 @@
|
|||||||
{{ .Name }}
|
{{ .Name }}
|
||||||
|
|
||||||
{{ .ImportPath }}
|
{{ .ImportPath }}
|
||||||
|
|
||||||
|
[go-i2p template file](/template.md)
|
Reference in New Issue
Block a user