Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
go
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
go
Commits
dd5adcc3
Commit
dd5adcc3
authored
Mar 10, 2011
by
Adam Langley
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
crypto/openpgp: bug fixes and fix misnamed function.
R=rsc, bradfitzwork CC=golang-dev
https://golang.org/cl/4244066
parent
daf33c3e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
9 deletions
+29
-9
src/pkg/crypto/openpgp/packet/packet.go
src/pkg/crypto/openpgp/packet/packet.go
+8
-8
src/pkg/crypto/openpgp/packet/packet_test.go
src/pkg/crypto/openpgp/packet/packet_test.go
+20
-0
src/pkg/crypto/openpgp/write.go
src/pkg/crypto/openpgp/write.go
+1
-1
No files found.
src/pkg/crypto/openpgp/packet/packet.go
View file @
dd5adcc3
...
...
@@ -169,7 +169,7 @@ func readHeader(r io.Reader) (tag packetType, length int64, contents io.Reader,
// serialiseHeader writes an OpenPGP packet header to w. See RFC 4880, section
// 4.2.
func
serialiseHeader
(
w
io
.
Writer
,
ptype
packetType
,
length
int
)
(
err
os
.
Error
)
{
var
buf
[
5
]
byte
var
buf
[
6
]
byte
var
n
int
buf
[
0
]
=
0x80
|
0x40
|
byte
(
ptype
)
...
...
@@ -178,16 +178,16 @@ func serialiseHeader(w io.Writer, ptype packetType, length int) (err os.Error) {
n
=
2
}
else
if
length
<
8384
{
length
-=
192
buf
[
1
]
=
byte
(
length
>>
8
)
buf
[
1
]
=
192
+
byte
(
length
>>
8
)
buf
[
2
]
=
byte
(
length
)
n
=
3
}
else
{
buf
[
0
]
=
255
buf
[
1
]
=
byte
(
length
>>
24
)
buf
[
2
]
=
byte
(
length
>>
16
)
buf
[
3
]
=
byte
(
length
>>
8
)
buf
[
4
]
=
byte
(
length
)
n
=
5
buf
[
1
]
=
255
buf
[
2
]
=
byte
(
length
>>
24
)
buf
[
3
]
=
byte
(
length
>>
16
)
buf
[
4
]
=
byte
(
length
>>
8
)
buf
[
5
]
=
byte
(
length
)
n
=
6
}
_
,
err
=
w
.
Write
(
buf
[
:
n
])
...
...
src/pkg/crypto/openpgp/packet/packet_test.go
View file @
dd5adcc3
...
...
@@ -190,3 +190,23 @@ func TestReadHeader(t *testing.T) {
}
}
}
func
TestSerialiseHeader
(
t
*
testing
.
T
)
{
tag
:=
packetTypePublicKey
lengths
:=
[]
int
{
0
,
1
,
2
,
64
,
192
,
193
,
8000
,
8384
,
8385
,
10000
}
for
_
,
length
:=
range
lengths
{
buf
:=
bytes
.
NewBuffer
(
nil
)
serialiseHeader
(
buf
,
tag
,
length
)
tag2
,
length2
,
_
,
err
:=
readHeader
(
buf
)
if
err
!=
nil
{
t
.
Errorf
(
"length %d, err: %s"
,
length
,
err
)
}
if
tag2
!=
tag
{
t
.
Errorf
(
"length %d, tag incorrect (got %d, want %d)"
,
length
,
tag2
,
tag
)
}
if
int
(
length2
)
!=
length
{
t
.
Errorf
(
"length %d, length incorrect (got %d)"
,
length
,
length2
)
}
}
}
src/pkg/crypto/openpgp/write.go
View file @
dd5adcc3
...
...
@@ -39,7 +39,7 @@ func DetachSignText(w io.Writer, signer *Entity, message io.Reader) os.Error {
// ArmoredDetachSignText signs message (after canonicalising the line endings)
// with the private key from signer (which must already have been decrypted)
// and writes an armored signature to w.
func
SignTextDetachedArmored
(
w
io
.
Writer
,
signer
*
Entity
,
message
io
.
Reader
)
os
.
Error
{
func
ArmoredDetachSignText
(
w
io
.
Writer
,
signer
*
Entity
,
message
io
.
Reader
)
os
.
Error
{
return
armoredDetachSign
(
w
,
signer
,
message
,
packet
.
SigTypeText
)
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment