Source File
signature_v3.go
Belonging Package
golang.org/x/crypto/openpgp/packet
package packet
import (
)
var [8]byte
if _, = readFull(, [:1]); != nil {
return
}
if [0] < 2 || [0] > 3 {
= errors.UnsupportedError("signature packet version " + strconv.Itoa(int([0])))
return
}
if _, = readFull(, [:1]); != nil {
return
}
if [0] != 5 {
= errors.UnsupportedError(
"invalid hashed material length " + strconv.Itoa(int([0])))
return
}
if _, = readFull(, [:2]); != nil {
return
}
.PubKeyAlgo = PublicKeyAlgorithm([0])
switch .PubKeyAlgo {
case PubKeyAlgoRSA, PubKeyAlgoRSASignOnly, PubKeyAlgoDSA:
default:
= errors.UnsupportedError("public key algorithm " + strconv.Itoa(int(.PubKeyAlgo)))
return
}
var bool
if .Hash, = s2k.HashIdToHash([1]); ! {
return errors.UnsupportedError("hash function " + strconv.Itoa(int([2])))
}
if _, = readFull(, .HashTag[:2]); != nil {
return
}
switch .PubKeyAlgo {
case PubKeyAlgoRSA, PubKeyAlgoRSASignOnly:
.RSASignature.bytes, .RSASignature.bitLength, = readMPI()
case PubKeyAlgoDSA:
if .DSASigR.bytes, .DSASigR.bitLength, = readMPI(); != nil {
return
}
.DSASigS.bytes, .DSASigS.bitLength, = readMPI()
default:
panic("unreachable")
}
return
}
[0] = byte(.PubKeyAlgo)
, := s2k.HashToHashId(.Hash)
if ! {
return errors.UnsupportedError(fmt.Sprintf("hash function %v", .Hash))
}
[1] =
copy([2:4], .HashTag[:])
if _, = .Write([:4]); != nil {
return
}
if .RSASignature.bytes == nil && .DSASigR.bytes == nil {
return errors.InvalidArgumentError("Signature: need to call Sign, SignUserId or SignKey before Serialize")
}
switch .PubKeyAlgo {
case PubKeyAlgoRSA, PubKeyAlgoRSASignOnly:
= writeMPIs(, .RSASignature)
case PubKeyAlgoDSA:
= writeMPIs(, .DSASigR, .DSASigS)
default:
panic("impossible")
}
return
![]() |
The pages are generated with Golds v0.3.2-preview. (GOOS=darwin GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds. |