Skip to content

Commit

Permalink
Detached verify was broken for messages shorter than 100 bytes
Browse files Browse the repository at this point in the history
  • Loading branch information
Steve Sanders committed Feb 2, 2016
1 parent ad9e594 commit 305748c
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 13 deletions.
1 change: 1 addition & 0 deletions go/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
- Detached pgp verify was broken for messages shorter than 100 bytes (PR: keybase/client#1862)
- Only restart driver if necessary when upgrading on Windows (PR: keybase/client#1842)
- Fix formatting for certain errors (PR: keybase/client#1830)
- Cache InputCanceled from SecretUI from KBFS crypto ops (PR: keybase/client#1795)
Expand Down
14 changes: 11 additions & 3 deletions go/engine/pgp_verify_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
keybase1 "github.com/keybase/client/go/protocol"
)

func TestPGPVerify(t *testing.T) {
func doVerify(t *testing.T, msg string) {
tc := SetupEngineTest(t, "PGPVerify")
defer tc.Cleanup()
fu := createFakeUserWithPGPSibkey(tc)
Expand All @@ -24,8 +24,6 @@ func TestPGPVerify(t *testing.T) {
PgpUI: &TestPgpUI{},
}

msg := "If you wish to stop receiving notifications from this topic, please click or visit the link below to unsubscribe:"

// create detached sig
detached := sign(ctx, tc, msg, keybase1.SignMode_DETACHED)

Expand Down Expand Up @@ -74,6 +72,16 @@ func TestPGPVerify(t *testing.T) {
// verify that attached signature
}

func TestPGPVerify(t *testing.T) {
msg := "If you wish to stop receiving notifications from this topic, please click or visit the link below to unsubscribe:"
doVerify(t, msg)
}

func TestPGPVerifyShortMsg(t *testing.T) {
msg := "less than 100 characters"
doVerify(t, msg)
}

func sign(ctx *Context, tc libkb.TestContext, msg string, mode keybase1.SignMode) string {
sink := libkb.NewBufferCloser()
arg := &PGPSignArg{
Expand Down
9 changes: 7 additions & 2 deletions go/libkb/stream_classifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func (p *StreamPeeker) Peek(buf []byte) (n int, err error) {
return 0, ErrCannotPeek
}
n, err = io.ReadFull(p.r, buf)
p.buf = append(p.buf, buf...)
p.buf = append(p.buf, buf[:n]...)
return n, err
}

Expand Down Expand Up @@ -236,7 +236,12 @@ func ClassifyStream(r io.Reader) (sc StreamClassification, out io.Reader, err er
var buf [100]byte
var n int
if n, err = peeker.Peek(buf[:]); err != nil {
return sc, peeker, err
// ErrUnexpectedEOF might just mean we read less than 100 bytes
if err == io.ErrUnexpectedEOF && len(buf) > 0 {
err = nil
} else {
return sc, peeker, err
}
}
sb := string(buf[:n])
switch {
Expand Down
17 changes: 9 additions & 8 deletions packaging/windows/build_prerelease.cmd
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
:: Build keybase.exe with prerelease options
cd %GOPATH%\src\github.com\keybase\client\go\keybase
set GOARCH=386
go generate
for /f %%i in ('winresource.exe -cb') do set KEYBASE_BUILD=%%i
echo %KEYBASE_BUILD%
go build -a -tags "prerelease production" -ldflags="-X github.com/keybase/client/go/libkb.CustomBuild=%KEYBASE_BUILD%"

:: Then build kbfsdokan
cd %GOPATH%\src\github.com\keybase\kbfs\kbfsdokan
go build -tags "production prerelease"
::cd %GOPATH%\src\github.com\keybase\kbfs\kbfsdokan
::go build -tags "production prerelease"

Then the desktop:
cd %GOPATH%\src\github.com\keybase\client\react-native\react
npm i
cd %GOPATH%\src\github.com\keybase\client\desktop
npm i
node package.js --arch ia32 --platform win32
:: Then the desktop:
::cd %GOPATH%\src\github.com\keybase\client\react-native\react
::npm i
::cd %GOPATH%\src\github.com\keybase\client\desktop
::npm i
::node package.js --arch ia32 --platform win32

0 comments on commit 305748c

Please sign in to comment.