diff --git a/build b/build index 7526f60..8b7dc80 100755 --- a/build +++ b/build @@ -4,7 +4,7 @@ # # - it tacks on a version number for use by the individual tools # - it supports git and mercurial version# -# +# # NB: # o the attempt at decoding dirty repo state for mercurial is # borked. It doesn't know about untracked files @@ -223,30 +223,64 @@ hosttool() { local bindir=$2 local src=$3 - local p=$(type -P $tool) - if [ -n "$p" ]; then - echo $p - return 0 - fi - - # from here - we want this dir to find all build artifacts - PATH=$PATH:$bindir - export PATH - p=$bindir/$tool if [ -x $p ]; then - echo $p return 0 fi + local tmpdir=/tmp/$tool.$$ + mkdir $tmpdir || die "can't make $tmpdir" + + # since go1.20 - install uses env vars to decide where to put + # build artifacts. Why are all the google tooling so bloody dev + # hostile! WTF is wrong with command line args?! + export GOBIN=$bindir + # build it and stash it in the hostdir echo "Building tool $tool from $src .." - $e $Go get -d $src || exit 1 - $e $Go build -o $p $src || exit 1 - echo $p + ( + cd $tmpdir + $e $Go install $src@latest || die "can't install $tool" + ) + $e rm -rf $tmpdir + return 0 } +# protobuf gen +buildproto() { + local pbgo=protoc-gen-go + local vtgo=protoc-gen-go-vtproto + local vtgo_src=github.com/planetscale/vtprotobuf/cmd/protoc-gen-go-vtproto + local pc + local args="$*" + + local pgen=$(type -p protoc) + local gogen=$(type -p $pbgo) + local vt=$Hostbindir/$vtgo + + [ -z $pgen ] && die "install protoc tools" + [ -z $gogen ] && die "install protoc-gen-go" + + # now install the vtproto generator + hosttool $vtgo $Hostbindir $vtgo_src + + for f in $args; do + local dn=$(dirname $f) + local bn=$(basename $f .proto) + + + $e $pgen \ + --go_out=. --plugin protoc-gen-go=$gogen \ + --go-vtproto_out=. --plugin protoc-gen-go-vtproto="$vt" \ + --go-vtproto_opt=features=marshal+unmarshal+size \ + $f || die "can't generate protobuf output for $f .." + done + + return 0 +} + +# the rest has to execute in the context of main shell (not funcs) hostos=$($Go env GOHOSTOS) || exit 1 hostcpu=$($Go env GOHOSTARCH) || exit 1 @@ -304,6 +338,7 @@ fi # This is where build outputs go Bindir=$PWD/bin/$cross Hostbindir=$PWD/bin/$hostos-$hostcpu +export PATH=$Hostbindir:$PATH [ -d $Bindir ] || mkdir -p $Bindir [ -d $Hostbindir ] || mkdir -p $Hostbindir @@ -335,32 +370,7 @@ fi # Do Protobufs if needed if [ -n "$Protobufs" ]; then set +e - slick=$Hostbindir/protoc-gen-gogoslick - slicksrc=github.com/gogo/protobuf/protoc-gen-gogoslick - for pc in protoc protoc-c; do - pc=$(type -p $pc) - [ -n "$pc" ] && break - done - - [ -z "$pc" ] && die "Need 'protoc' for building .." - - slick=$(hosttool protoc-gen-gogoslick $Hostbindir $slicksrc) || exit 1 - #if [ ! -f $slick ]; then - # echo "Building $slick .." - # $e go build -o $slick github.com/gogo/protobuf/protoc-gen-gogoslick || exit 1 - #i - - export PATH=$PATH:$Hostbindir - - for f in $Protobufs; do - dn=$(dirname $f) - bn=$(basename $f .proto) - of=$dn/${bn}.pb.go - if [ $f -nt $of ]; then - echo "Running $pc .." - $e $pc --gogoslick_out=. $f || exit 1 - fi - done + buildproto $Protobufs set -e fi @@ -398,7 +408,7 @@ case $Tool in echo "Building $Prodver ($rev), $cross $msg .." - for p in $all; do + for p in $all; do if echo $p | grep -q ':' ; then out=${p##*:} dir=${p%%:*} diff --git a/go.mod b/go.mod index 2720e13..6996b5c 100644 --- a/go.mod +++ b/go.mod @@ -4,14 +4,15 @@ go 1.21 require ( github.com/dchest/bcrypt_pbkdf v0.0.0-20150205184540-83f37f9c154a - github.com/gogo/protobuf v1.3.2 github.com/opencoff/go-utils v0.7.2 github.com/opencoff/pflag v1.0.6-sh1 golang.org/x/crypto v0.15.0 + google.golang.org/protobuf v1.31.0 gopkg.in/yaml.v2 v2.4.0 ) require ( golang.org/x/sys v0.14.0 // indirect golang.org/x/term v0.14.0 // indirect + golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect ) diff --git a/go.sum b/go.sum index e2a681c..55ed956 100644 --- a/go.sum +++ b/go.sum @@ -1,46 +1,24 @@ github.com/dchest/bcrypt_pbkdf v0.0.0-20150205184540-83f37f9c154a h1:saTgr5tMLFnmy/yg3qDTft4rE5DY2uJ/cCxCe3q0XTU= github.com/dchest/bcrypt_pbkdf v0.0.0-20150205184540-83f37f9c154a/go.mod h1:Bw9BbhOJVNR+t0jCqx2GC6zv0TGBsShs56Y3gfSCvl0= -github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= -github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= -github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= -github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= +github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= +github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU= +github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/opencoff/go-utils v0.7.2 h1:FK250pZ9UH+zdp1DlGyRARq7nULHEIkTVbpITTwwVXk= github.com/opencoff/go-utils v0.7.2/go.mod h1:8hMC3uc+N0wUMxpmW2yzM6FuhlCCxRST1Wj+cYntqFA= github.com/opencoff/pflag v1.0.6-sh1 h1:6RO8GgnpH928yu6earGDD01FnFT//bDJ1hCovcVVqY4= github.com/opencoff/pflag v1.0.6-sh1/go.mod h1:2bXtpAD/5h/2LarkbsRwiUxqnvB1nZBzn9Xjad1P41A= -github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.15.0 h1:frVn1TEaCEaZcn3Tmd7Y2b5KKPaZ+I32Q2OA3kYp5TA= golang.org/x/crypto v0.15.0/go.mod h1:4ChreQoLWfG3xLDer1WdlH5NdlQ3+mwnQq1YTKY+72g= -golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.14.0 h1:Vz7Qs629MkJkGyHxUlRHizWJRG2j8fbQKjELVSNhy7Q= golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.14.0 h1:LGK9IlZ8T9jvdy6cTdfKUCltatMFOehAQo9SRC46UQ8= golang.org/x/term v0.14.0/go.mod h1:TySc+nGkYR6qt8km8wUhuFRTVSMIX3XPR58y2lC8vww= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= +google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8= +google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= diff --git a/internal/pb/hdr.pb.go b/internal/pb/hdr.pb.go index 3a1d597..10d8e33 100644 --- a/internal/pb/hdr.pb.go +++ b/internal/pb/hdr.pb.go @@ -1,901 +1,258 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.28.1 +// protoc v3.21.12 // source: internal/pb/hdr.proto package pb import ( - bytes "bytes" - fmt "fmt" - proto "github.com/gogo/protobuf/proto" - io "io" - math "math" - math_bits "math/bits" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" - strings "strings" + sync "sync" ) -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package - -// // Every encrypted file starts with a header describing the // Block Size, Salt, Recipient keys etc. Header represents a // decoded version of this information. It is encoded in // protobuf format before writing to disk. type Header struct { - ChunkSize uint32 `protobuf:"varint,1,opt,name=chunk_size,json=chunkSize,proto3" json:"chunk_size,omitempty"` - Salt []byte `protobuf:"bytes,2,opt,name=salt,proto3" json:"salt,omitempty"` - Pk []byte `protobuf:"bytes,3,opt,name=pk,proto3" json:"pk,omitempty"` - Sender []byte `protobuf:"bytes,4,opt,name=sender,proto3" json:"sender,omitempty"` - Keys []*WrappedKey `protobuf:"bytes,5,rep,name=keys,proto3" json:"keys,omitempty"` + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + ChunkSize uint32 `protobuf:"varint,1,opt,name=chunk_size,json=chunkSize,proto3" json:"chunk_size,omitempty"` // encryption block size + Salt []byte `protobuf:"bytes,2,opt,name=salt,proto3" json:"salt,omitempty"` // master salt (nonces are derived from this) + Pk []byte `protobuf:"bytes,3,opt,name=pk,proto3" json:"pk,omitempty"` // ephemeral curve PK + Sender []byte `protobuf:"bytes,4,opt,name=sender,proto3" json:"sender,omitempty"` // sender signed artifacts + Keys []*WrappedKey `protobuf:"bytes,5,rep,name=keys,proto3" json:"keys,omitempty"` // list of wrapped receiver blocks } -func (m *Header) Reset() { *m = Header{} } -func (*Header) ProtoMessage() {} -func (*Header) Descriptor() ([]byte, []int) { - return fileDescriptor_c715362029a696e2, []int{0} -} -func (m *Header) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *Header) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_Header.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil +func (x *Header) Reset() { + *x = Header{} + if protoimpl.UnsafeEnabled { + mi := &file_internal_pb_hdr_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } } -func (m *Header) XXX_Merge(src proto.Message) { - xxx_messageInfo_Header.Merge(m, src) -} -func (m *Header) XXX_Size() int { - return m.Size() -} -func (m *Header) XXX_DiscardUnknown() { - xxx_messageInfo_Header.DiscardUnknown(m) + +func (x *Header) String() string { + return protoimpl.X.MessageStringOf(x) } -var xxx_messageInfo_Header proto.InternalMessageInfo +func (*Header) ProtoMessage() {} -func (m *Header) GetChunkSize() uint32 { - if m != nil { - return m.ChunkSize +func (x *Header) ProtoReflect() protoreflect.Message { + mi := &file_internal_pb_hdr_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Header.ProtoReflect.Descriptor instead. +func (*Header) Descriptor() ([]byte, []int) { + return file_internal_pb_hdr_proto_rawDescGZIP(), []int{0} +} + +func (x *Header) GetChunkSize() uint32 { + if x != nil { + return x.ChunkSize } return 0 } -func (m *Header) GetSalt() []byte { - if m != nil { - return m.Salt +func (x *Header) GetSalt() []byte { + if x != nil { + return x.Salt } return nil } -func (m *Header) GetPk() []byte { - if m != nil { - return m.Pk +func (x *Header) GetPk() []byte { + if x != nil { + return x.Pk } return nil } -func (m *Header) GetSender() []byte { - if m != nil { - return m.Sender +func (x *Header) GetSender() []byte { + if x != nil { + return x.Sender } return nil } -func (m *Header) GetKeys() []*WrappedKey { - if m != nil { - return m.Keys +func (x *Header) GetKeys() []*WrappedKey { + if x != nil { + return x.Keys } return nil } -// // A file encryption key is wrapped by a recipient specific public // key. WrappedKey describes such a wrapped key. type WrappedKey struct { - DKey []byte `protobuf:"bytes,1,opt,name=d_key,json=dKey,proto3" json:"d_key,omitempty"` - Nonce []byte `protobuf:"bytes,2,opt,name=nonce,proto3" json:"nonce,omitempty"` + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + DKey []byte `protobuf:"bytes,1,opt,name=d_key,json=dKey,proto3" json:"d_key,omitempty"` // encrypted data key + Nonce []byte `protobuf:"bytes,2,opt,name=nonce,proto3" json:"nonce,omitempty"` // nonce used for encryption +} + +func (x *WrappedKey) Reset() { + *x = WrappedKey{} + if protoimpl.UnsafeEnabled { + mi := &file_internal_pb_hdr_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *WrappedKey) String() string { + return protoimpl.X.MessageStringOf(x) } -func (m *WrappedKey) Reset() { *m = WrappedKey{} } func (*WrappedKey) ProtoMessage() {} + +func (x *WrappedKey) ProtoReflect() protoreflect.Message { + mi := &file_internal_pb_hdr_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use WrappedKey.ProtoReflect.Descriptor instead. func (*WrappedKey) Descriptor() ([]byte, []int) { - return fileDescriptor_c715362029a696e2, []int{1} -} -func (m *WrappedKey) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *WrappedKey) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_WrappedKey.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *WrappedKey) XXX_Merge(src proto.Message) { - xxx_messageInfo_WrappedKey.Merge(m, src) -} -func (m *WrappedKey) XXX_Size() int { - return m.Size() -} -func (m *WrappedKey) XXX_DiscardUnknown() { - xxx_messageInfo_WrappedKey.DiscardUnknown(m) + return file_internal_pb_hdr_proto_rawDescGZIP(), []int{1} } -var xxx_messageInfo_WrappedKey proto.InternalMessageInfo - -func (m *WrappedKey) GetDKey() []byte { - if m != nil { - return m.DKey +func (x *WrappedKey) GetDKey() []byte { + if x != nil { + return x.DKey } return nil } -func (m *WrappedKey) GetNonce() []byte { - if m != nil { - return m.Nonce +func (x *WrappedKey) GetNonce() []byte { + if x != nil { + return x.Nonce } return nil } -func init() { - proto.RegisterType((*Header)(nil), "pb.header") - proto.RegisterType((*WrappedKey)(nil), "pb.wrapped_key") -} +var File_internal_pb_hdr_proto protoreflect.FileDescriptor -func init() { proto.RegisterFile("internal/pb/hdr.proto", fileDescriptor_c715362029a696e2) } - -var fileDescriptor_c715362029a696e2 = []byte{ - // 262 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x4c, 0xd0, 0x3f, 0x4e, 0xf3, 0x40, - 0x10, 0x05, 0xf0, 0x1d, 0xc7, 0x89, 0xf4, 0x4d, 0xf2, 0x81, 0xb4, 0xfc, 0x91, 0x1b, 0x46, 0x56, - 0x68, 0x5c, 0x39, 0x12, 0x50, 0x50, 0xd3, 0xd2, 0x99, 0x03, 0x44, 0x76, 0x3c, 0x92, 0x2d, 0x47, - 0xeb, 0xd5, 0xda, 0x08, 0x39, 0x15, 0x25, 0x25, 0xc7, 0xe0, 0x28, 0x94, 0x2e, 0x53, 0xe2, 0x75, - 0x43, 0x99, 0x23, 0x20, 0x2d, 0x29, 0xe8, 0xde, 0xfb, 0x4d, 0xf3, 0x34, 0x78, 0x51, 0xaa, 0x96, - 0x8d, 0x4a, 0xb7, 0x2b, 0x9d, 0xad, 0x8a, 0xdc, 0xc4, 0xda, 0xd4, 0x6d, 0x2d, 0x3d, 0x9d, 0x2d, - 0xdf, 0x00, 0x67, 0x05, 0xa7, 0x39, 0x1b, 0x79, 0x85, 0xb8, 0x29, 0x9e, 0x55, 0xb5, 0x6e, 0xca, - 0x1d, 0x07, 0x10, 0x42, 0xf4, 0x3f, 0xf9, 0xe7, 0xe4, 0xa9, 0xdc, 0xb1, 0x94, 0xe8, 0x37, 0xe9, - 0xb6, 0x0d, 0xbc, 0x10, 0xa2, 0x45, 0xe2, 0xb2, 0x3c, 0x41, 0x4f, 0x57, 0xc1, 0xc4, 0x89, 0xa7, - 0x2b, 0x79, 0x89, 0xb3, 0x86, 0x55, 0xce, 0x26, 0xf0, 0x9d, 0x1d, 0x9b, 0xbc, 0x46, 0xbf, 0xe2, - 0xae, 0x09, 0xa6, 0xe1, 0x24, 0x9a, 0xdf, 0x9c, 0xc6, 0x3a, 0x8b, 0x5f, 0x4c, 0xaa, 0x35, 0xe7, - 0xeb, 0x8a, 0xbb, 0xc4, 0x1d, 0x97, 0xf7, 0x38, 0xff, 0x83, 0xf2, 0x0c, 0xa7, 0x2e, 0xb8, 0x25, - 0x8b, 0xc4, 0xcf, 0x1f, 0xb9, 0x93, 0xe7, 0x38, 0x55, 0xb5, 0xda, 0xf0, 0x71, 0xc5, 0x6f, 0x79, - 0xb8, 0xeb, 0x07, 0x12, 0xfb, 0x81, 0xc4, 0x61, 0x20, 0x78, 0xb5, 0x04, 0x1f, 0x96, 0xe0, 0xd3, - 0x12, 0xf4, 0x96, 0xe0, 0xcb, 0x12, 0x7c, 0x5b, 0x12, 0x07, 0x4b, 0xf0, 0x3e, 0x92, 0xe8, 0x47, - 0x12, 0xfb, 0x91, 0x44, 0x36, 0x73, 0x5f, 0xb8, 0xfd, 0x09, 0x00, 0x00, 0xff, 0xff, 0x06, 0x40, - 0x0b, 0xb4, 0x1e, 0x01, 0x00, 0x00, -} - -func (this *Header) Equal(that interface{}) bool { - if that == nil { - return this == nil - } - - that1, ok := that.(*Header) - if !ok { - that2, ok := that.(Header) - if ok { - that1 = &that2 - } else { - return false - } - } - if that1 == nil { - return this == nil - } else if this == nil { - return false - } - if this.ChunkSize != that1.ChunkSize { - return false - } - if !bytes.Equal(this.Salt, that1.Salt) { - return false - } - if !bytes.Equal(this.Pk, that1.Pk) { - return false - } - if !bytes.Equal(this.Sender, that1.Sender) { - return false - } - if len(this.Keys) != len(that1.Keys) { - return false - } - for i := range this.Keys { - if !this.Keys[i].Equal(that1.Keys[i]) { - return false - } - } - return true -} -func (this *WrappedKey) Equal(that interface{}) bool { - if that == nil { - return this == nil - } - - that1, ok := that.(*WrappedKey) - if !ok { - that2, ok := that.(WrappedKey) - if ok { - that1 = &that2 - } else { - return false - } - } - if that1 == nil { - return this == nil - } else if this == nil { - return false - } - if !bytes.Equal(this.DKey, that1.DKey) { - return false - } - if !bytes.Equal(this.Nonce, that1.Nonce) { - return false - } - return true -} -func (this *Header) GoString() string { - if this == nil { - return "nil" - } - s := make([]string, 0, 9) - s = append(s, "&pb.Header{") - s = append(s, "ChunkSize: "+fmt.Sprintf("%#v", this.ChunkSize)+",\n") - s = append(s, "Salt: "+fmt.Sprintf("%#v", this.Salt)+",\n") - s = append(s, "Pk: "+fmt.Sprintf("%#v", this.Pk)+",\n") - s = append(s, "Sender: "+fmt.Sprintf("%#v", this.Sender)+",\n") - if this.Keys != nil { - s = append(s, "Keys: "+fmt.Sprintf("%#v", this.Keys)+",\n") - } - s = append(s, "}") - return strings.Join(s, "") -} -func (this *WrappedKey) GoString() string { - if this == nil { - return "nil" - } - s := make([]string, 0, 6) - s = append(s, "&pb.WrappedKey{") - s = append(s, "DKey: "+fmt.Sprintf("%#v", this.DKey)+",\n") - s = append(s, "Nonce: "+fmt.Sprintf("%#v", this.Nonce)+",\n") - s = append(s, "}") - return strings.Join(s, "") -} -func valueToGoStringHdr(v interface{}, typ string) string { - rv := reflect.ValueOf(v) - if rv.IsNil() { - return "nil" - } - pv := reflect.Indirect(rv).Interface() - return fmt.Sprintf("func(v %v) *%v { return &v } ( %#v )", typ, typ, pv) -} -func (m *Header) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *Header) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Header) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Keys) > 0 { - for iNdEx := len(m.Keys) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Keys[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintHdr(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x2a - } - } - if len(m.Sender) > 0 { - i -= len(m.Sender) - copy(dAtA[i:], m.Sender) - i = encodeVarintHdr(dAtA, i, uint64(len(m.Sender))) - i-- - dAtA[i] = 0x22 - } - if len(m.Pk) > 0 { - i -= len(m.Pk) - copy(dAtA[i:], m.Pk) - i = encodeVarintHdr(dAtA, i, uint64(len(m.Pk))) - i-- - dAtA[i] = 0x1a - } - if len(m.Salt) > 0 { - i -= len(m.Salt) - copy(dAtA[i:], m.Salt) - i = encodeVarintHdr(dAtA, i, uint64(len(m.Salt))) - i-- - dAtA[i] = 0x12 - } - if m.ChunkSize != 0 { - i = encodeVarintHdr(dAtA, i, uint64(m.ChunkSize)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func (m *WrappedKey) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *WrappedKey) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *WrappedKey) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Nonce) > 0 { - i -= len(m.Nonce) - copy(dAtA[i:], m.Nonce) - i = encodeVarintHdr(dAtA, i, uint64(len(m.Nonce))) - i-- - dAtA[i] = 0x12 - } - if len(m.DKey) > 0 { - i -= len(m.DKey) - copy(dAtA[i:], m.DKey) - i = encodeVarintHdr(dAtA, i, uint64(len(m.DKey))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func encodeVarintHdr(dAtA []byte, offset int, v uint64) int { - offset -= sovHdr(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} -func (m *Header) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.ChunkSize != 0 { - n += 1 + sovHdr(uint64(m.ChunkSize)) - } - l = len(m.Salt) - if l > 0 { - n += 1 + l + sovHdr(uint64(l)) - } - l = len(m.Pk) - if l > 0 { - n += 1 + l + sovHdr(uint64(l)) - } - l = len(m.Sender) - if l > 0 { - n += 1 + l + sovHdr(uint64(l)) - } - if len(m.Keys) > 0 { - for _, e := range m.Keys { - l = e.Size() - n += 1 + l + sovHdr(uint64(l)) - } - } - return n -} - -func (m *WrappedKey) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.DKey) - if l > 0 { - n += 1 + l + sovHdr(uint64(l)) - } - l = len(m.Nonce) - if l > 0 { - n += 1 + l + sovHdr(uint64(l)) - } - return n -} - -func sovHdr(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozHdr(x uint64) (n int) { - return sovHdr(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (this *Header) String() string { - if this == nil { - return "nil" - } - repeatedStringForKeys := "[]*WrappedKey{" - for _, f := range this.Keys { - repeatedStringForKeys += strings.Replace(fmt.Sprintf("%v", f), "WrappedKey", "WrappedKey", 1) + "," - } - repeatedStringForKeys += "}" - s := strings.Join([]string{`&Header{`, - `ChunkSize:` + fmt.Sprintf("%v", this.ChunkSize) + `,`, - `Salt:` + fmt.Sprintf("%v", this.Salt) + `,`, - `Pk:` + fmt.Sprintf("%v", this.Pk) + `,`, - `Sender:` + fmt.Sprintf("%v", this.Sender) + `,`, - `Keys:` + repeatedStringForKeys + `,`, - `}`, - }, "") - return s -} -func (this *WrappedKey) String() string { - if this == nil { - return "nil" - } - s := strings.Join([]string{`&WrappedKey{`, - `DKey:` + fmt.Sprintf("%v", this.DKey) + `,`, - `Nonce:` + fmt.Sprintf("%v", this.Nonce) + `,`, - `}`, - }, "") - return s -} -func valueToStringHdr(v interface{}) string { - rv := reflect.ValueOf(v) - if rv.IsNil() { - return "nil" - } - pv := reflect.Indirect(rv).Interface() - return fmt.Sprintf("*%v", pv) -} -func (m *Header) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowHdr - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: header: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: header: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field ChunkSize", wireType) - } - m.ChunkSize = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowHdr - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.ChunkSize |= uint32(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Salt", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowHdr - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthHdr - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthHdr - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Salt = append(m.Salt[:0], dAtA[iNdEx:postIndex]...) - if m.Salt == nil { - m.Salt = []byte{} - } - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Pk", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowHdr - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthHdr - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthHdr - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Pk = append(m.Pk[:0], dAtA[iNdEx:postIndex]...) - if m.Pk == nil { - m.Pk = []byte{} - } - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Sender", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowHdr - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthHdr - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthHdr - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Sender = append(m.Sender[:0], dAtA[iNdEx:postIndex]...) - if m.Sender == nil { - m.Sender = []byte{} - } - iNdEx = postIndex - case 5: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Keys", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowHdr - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthHdr - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthHdr - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Keys = append(m.Keys, &WrappedKey{}) - if err := m.Keys[len(m.Keys)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipHdr(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthHdr - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *WrappedKey) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowHdr - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: wrapped_key: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: wrapped_key: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field DKey", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowHdr - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthHdr - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthHdr - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.DKey = append(m.DKey[:0], dAtA[iNdEx:postIndex]...) - if m.DKey == nil { - m.DKey = []byte{} - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Nonce", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowHdr - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthHdr - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthHdr - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Nonce = append(m.Nonce[:0], dAtA[iNdEx:postIndex]...) - if m.Nonce == nil { - m.Nonce = []byte{} - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipHdr(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthHdr - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func skipHdr(dAtA []byte) (n int, err error) { - l := len(dAtA) - iNdEx := 0 - depth := 0 - for iNdEx < l { - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowHdr - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - wireType := int(wire & 0x7) - switch wireType { - case 0: - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowHdr - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - iNdEx++ - if dAtA[iNdEx-1] < 0x80 { - break - } - } - case 1: - iNdEx += 8 - case 2: - var length int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowHdr - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - length |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if length < 0 { - return 0, ErrInvalidLengthHdr - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupHdr - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthHdr - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF +var file_internal_pb_hdr_proto_rawDesc = []byte{ + 0x0a, 0x15, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x70, 0x62, 0x2f, 0x68, 0x64, + 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x85, 0x01, 0x0a, 0x06, 0x68, 0x65, 0x61, 0x64, + 0x65, 0x72, 0x12, 0x1d, 0x0a, 0x0a, 0x63, 0x68, 0x75, 0x6e, 0x6b, 0x5f, 0x73, 0x69, 0x7a, 0x65, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x09, 0x63, 0x68, 0x75, 0x6e, 0x6b, 0x53, 0x69, 0x7a, + 0x65, 0x12, 0x12, 0x0a, 0x04, 0x73, 0x61, 0x6c, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, + 0x04, 0x73, 0x61, 0x6c, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x70, 0x6b, 0x18, 0x03, 0x20, 0x01, 0x28, + 0x0c, 0x52, 0x02, 0x70, 0x6b, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x18, + 0x04, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x06, 0x73, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x12, 0x20, 0x0a, + 0x04, 0x6b, 0x65, 0x79, 0x73, 0x18, 0x05, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x77, 0x72, + 0x61, 0x70, 0x70, 0x65, 0x64, 0x5f, 0x6b, 0x65, 0x79, 0x52, 0x04, 0x6b, 0x65, 0x79, 0x73, 0x22, + 0x38, 0x0a, 0x0b, 0x77, 0x72, 0x61, 0x70, 0x70, 0x65, 0x64, 0x5f, 0x6b, 0x65, 0x79, 0x12, 0x13, + 0x0a, 0x05, 0x64, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x64, + 0x4b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x6e, 0x6f, 0x6e, 0x63, 0x65, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x0c, 0x52, 0x05, 0x6e, 0x6f, 0x6e, 0x63, 0x65, 0x42, 0x0d, 0x5a, 0x0b, 0x69, 0x6e, 0x74, + 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( - ErrInvalidLengthHdr = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowHdr = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupHdr = fmt.Errorf("proto: unexpected end of group") + file_internal_pb_hdr_proto_rawDescOnce sync.Once + file_internal_pb_hdr_proto_rawDescData = file_internal_pb_hdr_proto_rawDesc ) + +func file_internal_pb_hdr_proto_rawDescGZIP() []byte { + file_internal_pb_hdr_proto_rawDescOnce.Do(func() { + file_internal_pb_hdr_proto_rawDescData = protoimpl.X.CompressGZIP(file_internal_pb_hdr_proto_rawDescData) + }) + return file_internal_pb_hdr_proto_rawDescData +} + +var file_internal_pb_hdr_proto_msgTypes = make([]protoimpl.MessageInfo, 2) +var file_internal_pb_hdr_proto_goTypes = []interface{}{ + (*Header)(nil), // 0: header + (*WrappedKey)(nil), // 1: wrapped_key +} +var file_internal_pb_hdr_proto_depIdxs = []int32{ + 1, // 0: header.keys:type_name -> wrapped_key + 1, // [1:1] is the sub-list for method output_type + 1, // [1:1] is the sub-list for method input_type + 1, // [1:1] is the sub-list for extension type_name + 1, // [1:1] is the sub-list for extension extendee + 0, // [0:1] is the sub-list for field type_name +} + +func init() { file_internal_pb_hdr_proto_init() } +func file_internal_pb_hdr_proto_init() { + if File_internal_pb_hdr_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_internal_pb_hdr_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Header); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_internal_pb_hdr_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*WrappedKey); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_internal_pb_hdr_proto_rawDesc, + NumEnums: 0, + NumMessages: 2, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_internal_pb_hdr_proto_goTypes, + DependencyIndexes: file_internal_pb_hdr_proto_depIdxs, + MessageInfos: file_internal_pb_hdr_proto_msgTypes, + }.Build() + File_internal_pb_hdr_proto = out.File + file_internal_pb_hdr_proto_rawDesc = nil + file_internal_pb_hdr_proto_goTypes = nil + file_internal_pb_hdr_proto_depIdxs = nil +} diff --git a/internal/pb/hdr.proto b/internal/pb/hdr.proto index a5a7c52..d3c8727 100644 --- a/internal/pb/hdr.proto +++ b/internal/pb/hdr.proto @@ -1,13 +1,8 @@ syntax="proto3"; -//import "gogoproto/gogo.proto" -package pb; +option go_package = "internal/pb"; -//option (gogoproto.marshaler_all) = true; -//option (gogoproto.sizer_all) = true; -//option (gogoproto.unmarshaler_all) = true; -//option (gogoproto.goproto_getters_all) = false; /* * Every encrypted file starts with a header describing the diff --git a/internal/pb/hdr_vtproto.pb.go b/internal/pb/hdr_vtproto.pb.go new file mode 100644 index 0000000..cc92c8a --- /dev/null +++ b/internal/pb/hdr_vtproto.pb.go @@ -0,0 +1,614 @@ +// Code generated by protoc-gen-go-vtproto. DO NOT EDIT. +// protoc-gen-go-vtproto version: v0.5.0 +// source: internal/pb/hdr.proto + +package pb + +import ( + fmt "fmt" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + io "io" + bits "math/bits" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +func (m *Header) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Header) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *Header) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if len(m.Keys) > 0 { + for iNdEx := len(m.Keys) - 1; iNdEx >= 0; iNdEx-- { + size, err := m.Keys[iNdEx].MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x2a + } + } + if len(m.Sender) > 0 { + i -= len(m.Sender) + copy(dAtA[i:], m.Sender) + i = encodeVarint(dAtA, i, uint64(len(m.Sender))) + i-- + dAtA[i] = 0x22 + } + if len(m.Pk) > 0 { + i -= len(m.Pk) + copy(dAtA[i:], m.Pk) + i = encodeVarint(dAtA, i, uint64(len(m.Pk))) + i-- + dAtA[i] = 0x1a + } + if len(m.Salt) > 0 { + i -= len(m.Salt) + copy(dAtA[i:], m.Salt) + i = encodeVarint(dAtA, i, uint64(len(m.Salt))) + i-- + dAtA[i] = 0x12 + } + if m.ChunkSize != 0 { + i = encodeVarint(dAtA, i, uint64(m.ChunkSize)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *WrappedKey) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *WrappedKey) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *WrappedKey) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if len(m.Nonce) > 0 { + i -= len(m.Nonce) + copy(dAtA[i:], m.Nonce) + i = encodeVarint(dAtA, i, uint64(len(m.Nonce))) + i-- + dAtA[i] = 0x12 + } + if len(m.DKey) > 0 { + i -= len(m.DKey) + copy(dAtA[i:], m.DKey) + i = encodeVarint(dAtA, i, uint64(len(m.DKey))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarint(dAtA []byte, offset int, v uint64) int { + offset -= sov(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *Header) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.ChunkSize != 0 { + n += 1 + sov(uint64(m.ChunkSize)) + } + l = len(m.Salt) + if l > 0 { + n += 1 + l + sov(uint64(l)) + } + l = len(m.Pk) + if l > 0 { + n += 1 + l + sov(uint64(l)) + } + l = len(m.Sender) + if l > 0 { + n += 1 + l + sov(uint64(l)) + } + if len(m.Keys) > 0 { + for _, e := range m.Keys { + l = e.SizeVT() + n += 1 + l + sov(uint64(l)) + } + } + n += len(m.unknownFields) + return n +} + +func (m *WrappedKey) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.DKey) + if l > 0 { + n += 1 + l + sov(uint64(l)) + } + l = len(m.Nonce) + if l > 0 { + n += 1 + l + sov(uint64(l)) + } + n += len(m.unknownFields) + return n +} + +func sov(x uint64) (n int) { + return (bits.Len64(x|1) + 6) / 7 +} +func soz(x uint64) (n int) { + return sov(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *Header) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Header: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Header: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ChunkSize", wireType) + } + m.ChunkSize = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ChunkSize |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Salt", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLength + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Salt = append(m.Salt[:0], dAtA[iNdEx:postIndex]...) + if m.Salt == nil { + m.Salt = []byte{} + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pk", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLength + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Pk = append(m.Pk[:0], dAtA[iNdEx:postIndex]...) + if m.Pk == nil { + m.Pk = []byte{} + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Sender", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLength + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Sender = append(m.Sender[:0], dAtA[iNdEx:postIndex]...) + if m.Sender == nil { + m.Sender = []byte{} + } + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Keys", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Keys = append(m.Keys, &WrappedKey{}) + if err := m.Keys[len(m.Keys)-1].UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *WrappedKey) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: WrappedKey: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: WrappedKey: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DKey", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLength + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.DKey = append(m.DKey[:0], dAtA[iNdEx:postIndex]...) + if m.DKey == nil { + m.DKey = []byte{} + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Nonce", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLength + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Nonce = append(m.Nonce[:0], dAtA[iNdEx:postIndex]...) + if m.Nonce == nil { + m.Nonce = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} + +func skip(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflow + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflow + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflow + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLength + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroup + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLength + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLength = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflow = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroup = fmt.Errorf("proto: unexpected end of group") +) diff --git a/internal/pb/helpers.go b/internal/pb/helpers.go new file mode 100644 index 0000000..39b7d59 --- /dev/null +++ b/internal/pb/helpers.go @@ -0,0 +1,16 @@ +// helper routines to maintain backwards compat with gogo + +package pb + + +func (m *Header) Size() int { + return m.SizeVT() +} + +func (m *Header) MarshalTo(buf []byte) (int, error) { + return m.MarshalToVT(buf) +} + +func (m *Header) Unmarshal(buf []byte) error { + return m.UnmarshalVT(buf) +}