forked from toolshed/abra
chore: make deps, go mod vendor
This commit is contained in:
go.modgo.summodules.txt
vendor
dario.cat
github.com
ProtonMail
go-crypto
ocb
openpgp
armor
canonical_text.goecdh
ed25519
ed448
errors
internal
key_generation.gokeys.gopacket
aead_crypter.gocompressed.goconfig.goconfig_v5.goencrypted_key.goliteral.gomarker.goone_pass_signature.goopaque.gopacket.gopacket_sequence.gopacket_unsupported.gopadding.goprivate_key.gopublic_key.goreader.gorecipient.gosignature.gosymmetric_key_encrypted.gosymmetrically_encrypted.gosymmetrically_encrypted_aead.gosymmetrically_encrypted_mdc.gouserattribute.gouserid.go
read.goread_write_test_data.gos2k
write.gox25519
x448
charmbracelet
lipgloss
x
ansi
cloudflare
containerd
containerd
cyphar
filepath-securejoin
docker
cli
docker
go-git
go-billy
go-viper
mapstructure
grpc-ecosystem
grpc-gateway
klauspost
compress
mattn
go-runewidth
moby
sys
prometheus
schollz
progressbar
skeema
knownhosts
stretchr
go.opentelemetry.io
contrib
instrumentation
net
http
otelhttp
otel
.gitignore.golangci.ymlCHANGELOG.mdCODEOWNERSCONTRIBUTING.mdMakefileREADME.mdRELEASING.md
attribute
baggage
codes
doc.goexporters
otlp
otlpmetric
otlpmetricgrpc
otlptrace
internal
metric
renovate.jsonsdk
instrumentation
metric
config.godoc.goexemplar.gomanual_reader.gometer.goperiodic_reader.gopipeline.goprovider.goreader.goversion.goview.go
exemplar
README.mddoc.goexemplar.gofilter.gofixed_size_reservoir.gohistogram_reservoir.goreservoir.gostorage.govalue.go
instrument.gointernal
aggregate
aggregate.godrop.goexemplar.goexponential_histogram.gofiltered_reservoir.gohistogram.golastvalue.gosum.go
exemplar
x
resource
trace
version.gosemconv
trace
verify_examples.shverify_released_changelog.shversion.goversions.yamlgolang.org
x
crypto
exp
net
LICENSE
http2
sync
sys
LICENSE
cpu
asm_darwin_x86_gc.scpu.gocpu_arm64.gocpu_darwin_x86.gocpu_gc_x86.gocpu_gc_x86.scpu_gccgo_x86.gocpu_linux_arm64.gocpu_linux_noinit.gocpu_linux_riscv64.gocpu_other_x86.gocpu_riscv64.gocpu_x86.gosyscall_darwin_x86_gc.go
unix
README.mdioctl_linux.gomkerrors.shsyscall_aix.gosyscall_darwin.gosyscall_hurd.gosyscall_linux.gosyscall_linux_arm64.gosyscall_linux_loong64.gosyscall_linux_riscv64.gosyscall_openbsd.gosyscall_zos_s390x.govgetrandom_linux.govgetrandom_unsupported.gozerrors_darwin_amd64.gozerrors_darwin_arm64.gozerrors_linux.gozerrors_linux_386.gozerrors_linux_amd64.gozerrors_linux_arm.gozerrors_linux_arm64.gozerrors_linux_loong64.gozerrors_linux_mips.gozerrors_linux_mips64.gozerrors_linux_mips64le.gozerrors_linux_mipsle.gozerrors_linux_ppc.gozerrors_linux_ppc64.gozerrors_linux_ppc64le.gozerrors_linux_riscv64.gozerrors_linux_s390x.gozerrors_linux_sparc64.gozerrors_zos_s390x.gozsyscall_darwin_amd64.gozsyscall_darwin_amd64.szsyscall_darwin_arm64.gozsyscall_darwin_arm64.szsyscall_linux.gozsyscall_openbsd_386.gozsyscall_openbsd_386.szsyscall_openbsd_amd64.gozsyscall_openbsd_amd64.szsyscall_openbsd_arm.gozsyscall_openbsd_arm.szsyscall_openbsd_arm64.gozsyscall_openbsd_arm64.szsyscall_openbsd_mips64.gozsyscall_openbsd_mips64.szsyscall_openbsd_ppc64.gozsyscall_openbsd_ppc64.szsyscall_openbsd_riscv64.gozsyscall_openbsd_riscv64.szsysnum_linux_386.gozsysnum_linux_amd64.gozsysnum_linux_arm.gozsysnum_linux_arm64.gozsysnum_linux_loong64.gozsysnum_linux_mips.gozsysnum_linux_mips64.gozsysnum_linux_mips64le.gozsysnum_linux_mipsle.gozsysnum_linux_ppc.gozsysnum_linux_ppc64.gozsysnum_linux_ppc64le.gozsysnum_linux_riscv64.gozsysnum_linux_s390x.gozsysnum_linux_sparc64.goztypes_darwin_amd64.goztypes_darwin_arm64.goztypes_freebsd_386.goztypes_freebsd_amd64.goztypes_freebsd_arm.goztypes_freebsd_arm64.goztypes_freebsd_riscv64.goztypes_linux.goztypes_linux_riscv64.goztypes_zos_s390x.go
windows
term
text
time
google.golang.org
grpc
CONTRIBUTING.mdMAINTAINERS.mdSECURITY.mdclientconn.gocodec.go
backoff
balancer
balancer_wrapper.gobinarylog
grpc_binarylog_v1
credentials
dialoptions.godoc.goencoding
experimental
grpclog
health
grpc_health_v1
internal
balancer
gracefulswitch
binarylog
channelz
envconfig
experimental.gogrpclog
grpcsync
grpcutil
idle
internal.goresolver
stats
status
syscall
tcp_keepalive_unix.gotcp_keepalive_windows.gotransport
keepalive
mem
metadata
preloader.goregenerate.shresolver_wrapper.gorpc_util.goserver.goshared_buffer_pool.gostats
stream.gostream_interfaces.goversion.goprotobuf
encoding
internal
descopts
editiondefaults
filedesc
genid
impl
codec_extension.gocodec_field.gocodec_message.gocodec_reflect.gocodec_unsafe.goconvert.goencode.goequal.golegacy_extension.gomessage.gopointer_reflect.gopointer_unsafe.go
strs
version
proto
reflect
runtime
protoiface
types
known
anypb
durationpb
fieldmaskpb
structpb
timestamppb
wrapperspb
159
vendor/github.com/ProtonMail/go-crypto/openpgp/packet/reader.go
generated
vendored
159
vendor/github.com/ProtonMail/go-crypto/openpgp/packet/reader.go
generated
vendored
@ -10,6 +10,12 @@ import (
|
||||
"github.com/ProtonMail/go-crypto/openpgp/errors"
|
||||
)
|
||||
|
||||
type PacketReader interface {
|
||||
Next() (p Packet, err error)
|
||||
Push(reader io.Reader) (err error)
|
||||
Unread(p Packet)
|
||||
}
|
||||
|
||||
// Reader reads packets from an io.Reader and allows packets to be 'unread' so
|
||||
// that they result from the next call to Next.
|
||||
type Reader struct {
|
||||
@ -26,37 +32,81 @@ type Reader struct {
|
||||
const maxReaders = 32
|
||||
|
||||
// Next returns the most recently unread Packet, or reads another packet from
|
||||
// the top-most io.Reader. Unknown packet types are skipped.
|
||||
// the top-most io.Reader. Unknown/unsupported/Marker packet types are skipped.
|
||||
func (r *Reader) Next() (p Packet, err error) {
|
||||
for {
|
||||
p, err := r.read()
|
||||
if err == io.EOF {
|
||||
break
|
||||
} else if err != nil {
|
||||
if _, ok := err.(errors.UnknownPacketTypeError); ok {
|
||||
continue
|
||||
}
|
||||
if _, ok := err.(errors.UnsupportedError); ok {
|
||||
switch p.(type) {
|
||||
case *SymmetricallyEncrypted, *AEADEncrypted, *Compressed, *LiteralData:
|
||||
return nil, err
|
||||
}
|
||||
continue
|
||||
}
|
||||
return nil, err
|
||||
} else {
|
||||
//A marker packet MUST be ignored when received
|
||||
switch p.(type) {
|
||||
case *Marker:
|
||||
continue
|
||||
}
|
||||
return p, nil
|
||||
}
|
||||
}
|
||||
return nil, io.EOF
|
||||
}
|
||||
|
||||
// Next returns the most recently unread Packet, or reads another packet from
|
||||
// the top-most io.Reader. Unknown/Marker packet types are skipped while unsupported
|
||||
// packets are returned as UnsupportedPacket type.
|
||||
func (r *Reader) NextWithUnsupported() (p Packet, err error) {
|
||||
for {
|
||||
p, err = r.read()
|
||||
if err == io.EOF {
|
||||
break
|
||||
} else if err != nil {
|
||||
if _, ok := err.(errors.UnknownPacketTypeError); ok {
|
||||
continue
|
||||
}
|
||||
if casteErr, ok := err.(errors.UnsupportedError); ok {
|
||||
return &UnsupportedPacket{
|
||||
IncompletePacket: p,
|
||||
Error: casteErr,
|
||||
}, nil
|
||||
}
|
||||
return
|
||||
} else {
|
||||
//A marker packet MUST be ignored when received
|
||||
switch p.(type) {
|
||||
case *Marker:
|
||||
continue
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
return nil, io.EOF
|
||||
}
|
||||
|
||||
func (r *Reader) read() (p Packet, err error) {
|
||||
if len(r.q) > 0 {
|
||||
p = r.q[len(r.q)-1]
|
||||
r.q = r.q[:len(r.q)-1]
|
||||
return
|
||||
}
|
||||
|
||||
for len(r.readers) > 0 {
|
||||
p, err = Read(r.readers[len(r.readers)-1])
|
||||
if err == nil {
|
||||
return
|
||||
}
|
||||
if err == io.EOF {
|
||||
r.readers = r.readers[:len(r.readers)-1]
|
||||
continue
|
||||
}
|
||||
// TODO: Add strict mode that rejects unknown packets, instead of ignoring them.
|
||||
if _, ok := err.(errors.UnknownPacketTypeError); ok {
|
||||
continue
|
||||
}
|
||||
if _, ok := err.(errors.UnsupportedError); ok {
|
||||
switch p.(type) {
|
||||
case *SymmetricallyEncrypted, *AEADEncrypted, *Compressed, *LiteralData:
|
||||
return nil, err
|
||||
}
|
||||
continue
|
||||
}
|
||||
return nil, err
|
||||
return p, err
|
||||
}
|
||||
|
||||
return nil, io.EOF
|
||||
}
|
||||
|
||||
@ -84,3 +134,76 @@ func NewReader(r io.Reader) *Reader {
|
||||
readers: []io.Reader{r},
|
||||
}
|
||||
}
|
||||
|
||||
// CheckReader is similar to Reader but additionally
|
||||
// uses the pushdown automata to verify the read packet sequence.
|
||||
type CheckReader struct {
|
||||
Reader
|
||||
verifier *SequenceVerifier
|
||||
fullyRead bool
|
||||
}
|
||||
|
||||
// Next returns the most recently unread Packet, or reads another packet from
|
||||
// the top-most io.Reader. Unknown packet types are skipped.
|
||||
// If the read packet sequence does not conform to the packet composition
|
||||
// rules in rfc4880, it returns an error.
|
||||
func (r *CheckReader) Next() (p Packet, err error) {
|
||||
if r.fullyRead {
|
||||
return nil, io.EOF
|
||||
}
|
||||
if len(r.q) > 0 {
|
||||
p = r.q[len(r.q)-1]
|
||||
r.q = r.q[:len(r.q)-1]
|
||||
return
|
||||
}
|
||||
var errMsg error
|
||||
for len(r.readers) > 0 {
|
||||
p, errMsg, err = ReadWithCheck(r.readers[len(r.readers)-1], r.verifier)
|
||||
if errMsg != nil {
|
||||
err = errMsg
|
||||
return
|
||||
}
|
||||
if err == nil {
|
||||
return
|
||||
}
|
||||
if err == io.EOF {
|
||||
r.readers = r.readers[:len(r.readers)-1]
|
||||
continue
|
||||
}
|
||||
//A marker packet MUST be ignored when received
|
||||
switch p.(type) {
|
||||
case *Marker:
|
||||
continue
|
||||
}
|
||||
if _, ok := err.(errors.UnknownPacketTypeError); ok {
|
||||
continue
|
||||
}
|
||||
if _, ok := err.(errors.UnsupportedError); ok {
|
||||
switch p.(type) {
|
||||
case *SymmetricallyEncrypted, *AEADEncrypted, *Compressed, *LiteralData:
|
||||
return nil, err
|
||||
}
|
||||
continue
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
if errMsg = r.verifier.Next(EOSSymbol); errMsg != nil {
|
||||
return nil, errMsg
|
||||
}
|
||||
if errMsg = r.verifier.AssertValid(); errMsg != nil {
|
||||
return nil, errMsg
|
||||
}
|
||||
r.fullyRead = true
|
||||
return nil, io.EOF
|
||||
}
|
||||
|
||||
func NewCheckReader(r io.Reader) *CheckReader {
|
||||
return &CheckReader{
|
||||
Reader: Reader{
|
||||
q: nil,
|
||||
readers: []io.Reader{r},
|
||||
},
|
||||
verifier: NewSequenceVerifier(),
|
||||
fullyRead: false,
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user