resolve setSignature TODO

This commit is contained in:
Jack Doan 2024-11-05 09:12:30 -05:00
parent f30085eab8
commit 50850eeaf2
4 changed files with 8 additions and 2 deletions

View File

@ -329,6 +329,9 @@ func (c *certificateV1) marshalForSigning() ([]byte, error) {
} }
func (c *certificateV1) setSignature(b []byte) error { func (c *certificateV1) setSignature(b []byte) error {
if len(b) == 0 {
return ErrEmptySignature
}
c.signature = b c.signature = b
return nil return nil
} }

View File

@ -390,6 +390,9 @@ func (c *certificateV2) marshalForSigning() ([]byte, error) {
} }
func (c *certificateV2) setSignature(b []byte) error { func (c *certificateV2) setSignature(b []byte) error {
if len(b) == 0 {
return ErrEmptySignature
}
c.signature = b c.signature = b
return nil return nil
} }

View File

@ -31,4 +31,5 @@ var (
ErrNoPayload = errors.New("provided payload was empty") ErrNoPayload = errors.New("provided payload was empty")
ErrMissingDetails = errors.New("certificate did not contain details") ErrMissingDetails = errors.New("certificate did not contain details")
ErrEmptySignature = errors.New("empty signature")
) )

View File

@ -36,7 +36,7 @@ type beingSignedCertificate interface {
// marshalForSigning returns the bytes that should be signed // marshalForSigning returns the bytes that should be signed
marshalForSigning() ([]byte, error) marshalForSigning() ([]byte, error)
// setSignature sets the signature for the certificate that has just been signed // setSignature sets the signature for the certificate that has just been signed. The signature must not be blank.
setSignature([]byte) error setSignature([]byte) error
} }
@ -138,7 +138,6 @@ func (t *TBSCertificate) SignWith(signer Certificate, curve Curve, sp SignerLamb
return nil, err return nil, err
} }
//TODO: check if we have sig bytes?
err = c.setSignature(sig) err = c.setSignature(sig)
if err != nil { if err != nil {
return nil, err return nil, err