Ver Fonte

resolve setSignature TODO

Jack Doan há 10 meses atrás
pai
commit
50850eeaf2
4 ficheiros alterados com 8 adições e 2 exclusões
  1. 3 0
      cert/cert_v1.go
  2. 3 0
      cert/cert_v2.go
  3. 1 0
      cert/errors.go
  4. 1 2
      cert/sign.go

+ 3 - 0
cert/cert_v1.go

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

+ 3 - 0
cert/cert_v2.go

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

+ 1 - 0
cert/errors.go

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

+ 1 - 2
cert/sign.go

@@ -36,7 +36,7 @@ type beingSignedCertificate interface {
 	// marshalForSigning returns the bytes that should be signed
 	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
 }
 
@@ -138,7 +138,6 @@ func (t *TBSCertificate) SignWith(signer Certificate, curve Curve, sp SignerLamb
 		return nil, err
 	}
 
-	//TODO: check if we have sig bytes?
 	err = c.setSignature(sig)
 	if err != nil {
 		return nil, err