mirror of
https://github.com/go-i2p/go-i2p.git
synced 2025-07-04 21:55:18 -04:00
more keys and cert testing
This commit is contained in:
@ -66,6 +66,9 @@ type KeysAndCert []byte
|
||||
//
|
||||
func (keys_and_cert KeysAndCert) PublicKey() (key crypto.PublicKey, err error) {
|
||||
cert, err := keys_and_cert.Certificate()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
cert_len, err := cert.Length()
|
||||
if err != nil {
|
||||
return
|
||||
@ -109,6 +112,9 @@ func (keys_and_cert KeysAndCert) PublicKey() (key crypto.PublicKey, err error) {
|
||||
//
|
||||
func (keys_and_cert KeysAndCert) SigningPublicKey() (signing_public_key crypto.SigningPublicKey, err error) {
|
||||
cert, err := keys_and_cert.Certificate()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
cert_len, err := cert.Length()
|
||||
if err != nil {
|
||||
return
|
||||
|
@ -42,6 +42,27 @@ func TestSigningPublicKeyWithOtherCertType(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestReadKeysAndCertWithMissingData(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
|
||||
cert_data := make([]byte, 128)
|
||||
keys_and_cert, remainder, err := ReadKeysAndCert(cert_data)
|
||||
assert.Equal(0, len(remainder))
|
||||
if assert.NotNil(err) {
|
||||
assert.Equal("error parsing KeysAndCert: data is smaller than minimum valid size", err.Error())
|
||||
}
|
||||
|
||||
_, err = keys_and_cert.PublicKey()
|
||||
if assert.NotNil(err) {
|
||||
assert.Equal("error parsing KeysAndCert: data is smaller than minimum valid size", err.Error())
|
||||
}
|
||||
_, err = keys_and_cert.SigningPublicKey()
|
||||
if assert.NotNil(err) {
|
||||
assert.Equal("error parsing KeysAndCert: data is smaller than minimum valid size", err.Error())
|
||||
}
|
||||
_, err = keys_and_cert.Certificate()
|
||||
if assert.NotNil(err) {
|
||||
assert.Equal("error parsing KeysAndCert: data is smaller than minimum valid size", err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
func TestReadKeysAndCertWithMissingCertData(t *testing.T) {
|
||||
|
Reference in New Issue
Block a user