Skip to content
This repository has been archived by the owner on Jun 9, 2024. It is now read-only.

validator/lib: fix dropped errors #87

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions validator/lib/cert.go
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,9 @@ func DecodeIPAddressBlock(data []byte) ([]IPCertificateInformation, error) {

a, _ := DecodeIPMinMax(ipaddrfam.AddressFamily, addrRange.Min, false)
b, err := DecodeIPMinMax(ipaddrfam.AddressFamily, addrRange.Max, true)
if err != nil {
return ipaddresses, err
}
ipaddresses = append(ipaddresses, &IPAddressRange{
Min: a,
Max: b,
Expand Down
4 changes: 3 additions & 1 deletion validator/lib/cms.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,9 @@ func (cms *CMS) Sign(rand io.Reader, ski []byte, encap []byte, priv interface{},
h.Write(encap)
messageDigest := h.Sum(nil)
messageDigestEnc, err := asn1.Marshal(messageDigest)

if err != nil {
return err
}
digestAttribute := Attribute{
AttrType: MessageDigest,
AttrValue: []asn1.RawValue{asn1.RawValue{FullBytes: messageDigestEnc}},
Expand Down
6 changes: 5 additions & 1 deletion validator/lib/manifest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ import (
"crypto/x509"
"crypto/x509/pkix"
"encoding/asn1"
"github.com/stretchr/testify/assert"
"math/big"
"testing"
"time"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

func MakeMFTContent() ManifestContent {
Expand Down Expand Up @@ -50,6 +52,7 @@ func TestEncodeMFTContent(t *testing.T) {
assert.Nil(t, err)

privkey, err := rsa.GenerateKey(rand.Reader, 1024)
require.NoError(t, err)
ski := []byte{1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5}

cert := &x509.Certificate{
Expand All @@ -64,6 +67,7 @@ func TestEncodeMFTContent(t *testing.T) {
}
pubkey := privkey.Public()
certBytes, err := x509.CreateCertificate(rand.Reader, cert, cert, pubkey, privkey)
require.NoError(t, err)

encap, _ := EContentToEncap(contentEnc.EContent.FullBytes)
err = cms.Sign(rand.Reader, ski, encap, privkey, certBytes)
Expand Down
4 changes: 3 additions & 1 deletion validator/lib/roa.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,9 @@ func (cf *DecoderConfig) DecodeROA(data []byte) (*RPKIROA, error) {

var rawroa ROA
_, err = asn1.Unmarshal(c.SignedData.EncapContentInfo.FullBytes, &rawroa)

if err != nil {
return nil, err
}
var inner asn1.RawValue
_, err = asn1.Unmarshal(rawroa.EContent.Bytes, &inner)
if err != nil {
Expand Down
6 changes: 5 additions & 1 deletion validator/lib/roa_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@ import (
"crypto/x509"
"crypto/x509/pkix"
"encoding/asn1"
"github.com/stretchr/testify/assert"
"math/big"
"net"
"testing"
"time"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

func MakeROAEntries() []*ROAEntry {
Expand Down Expand Up @@ -41,6 +43,7 @@ func TestEncodeROA(t *testing.T) {
assert.Nil(t, err)

privkey, err := rsa.GenerateKey(rand.Reader, 1024)
require.NoError(t, err)
ski := []byte{1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5}

cert := &x509.Certificate{
Expand All @@ -55,6 +58,7 @@ func TestEncodeROA(t *testing.T) {
}
pubkey := privkey.Public()
certBytes, err := x509.CreateCertificate(rand.Reader, cert, cert, pubkey, privkey)
require.NoError(t, err)

encap, _ := EContentToEncap(entriesEnc.EContent.FullBytes)
err = cms.Sign(rand.Reader, ski, encap, privkey, certBytes)
Expand Down
7 changes: 6 additions & 1 deletion validator/lib/xml_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ import (
"crypto/x509/pkix"
"encoding/asn1"
"encoding/hex"
"github.com/stretchr/testify/assert"
"math/big"
"strings"
"testing"
"time"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

func TestEncodeXMLContent(t *testing.T) {
Expand All @@ -24,6 +26,7 @@ func TestEncodeXMLContent(t *testing.T) {
assert.Nil(t, err)

privkeyParent, err := rsa.GenerateKey(rand.Reader, 2048)
require.NoError(t, err)
skiParent, _ := HashRSAPublicKey(*privkeyParent.Public().(*rsa.PublicKey))

parentCert := &x509.Certificate{
Expand All @@ -38,6 +41,7 @@ func TestEncodeXMLContent(t *testing.T) {
}

privkey, err := rsa.GenerateKey(rand.Reader, 2048)
require.NoError(t, err)
ski, _ := HashRSAPublicKey(*privkey.Public().(*rsa.PublicKey))

cert := &x509.Certificate{
Expand All @@ -52,6 +56,7 @@ func TestEncodeXMLContent(t *testing.T) {
}
pubkey := privkey.Public()
certBytes, err := x509.CreateCertificate(rand.Reader, cert, parentCert, pubkey, privkeyParent)
require.NoError(t, err)

crls, err := parentCert.CreateCRL(rand.Reader, privkeyParent, []pkix.RevokedCertificate{}, now.Add(-time.Minute*5), now.Add(time.Minute*5))
assert.Nil(t, err)
Expand Down