~juju-qa/ubuntu/xenial/juju/2.0-rc2

« back to all changes in this revision

Viewing changes to src/golang.org/x/crypto/openpgp/packet/signature.go

  • Committer: Nicholas Skaggs
  • Date: 2016-09-30 14:39:30 UTC
  • mfrom: (1.8.1)
  • Revision ID: nicholas.skaggs@canonical.com-20160930143930-vwwhrefh6ftckccy
import upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
8
8
        "bytes"
9
9
        "crypto"
10
10
        "crypto/dsa"
 
11
        "crypto/ecdsa"
11
12
        "crypto/rsa"
12
13
        "encoding/binary"
13
14
        "hash"
532
533
                        sig.DSASigS.bytes = s.Bytes()
533
534
                        sig.DSASigS.bitLength = uint16(8 * len(sig.DSASigS.bytes))
534
535
                }
 
536
        case PubKeyAlgoECDSA:
 
537
                r, s, err := ecdsa.Sign(config.Random(), priv.PrivateKey.(*ecdsa.PrivateKey), digest)
 
538
                if err == nil {
 
539
                        sig.ECDSASigR = fromBig(r)
 
540
                        sig.ECDSASigS = fromBig(s)
 
541
                }
535
542
        default:
536
543
                err = errors.UnsupportedError("public key algorithm: " + strconv.Itoa(int(sig.PubKeyAlgo)))
537
544
        }
546
553
func (sig *Signature) SignUserId(id string, pub *PublicKey, priv *PrivateKey, config *Config) error {
547
554
        h, err := userIdSignatureHash(id, pub, sig.Hash)
548
555
        if err != nil {
549
 
                return nil
 
556
                return err
550
557
        }
551
558
        return sig.Sign(h, priv, config)
552
559
}