Commit ee23ab16 authored by Adam Langley's avatar Adam Langley

crypto/openpgp: s/serialise/serialize/

(No code changes, Americanization only.)

R=rsc, bradfitzwork
CC=golang-dev
https://golang.org/cl/4250075
parent dc06ad5a
...@@ -166,9 +166,9 @@ func readHeader(r io.Reader) (tag packetType, length int64, contents io.Reader, ...@@ -166,9 +166,9 @@ func readHeader(r io.Reader) (tag packetType, length int64, contents io.Reader,
return return
} }
// serialiseHeader writes an OpenPGP packet header to w. See RFC 4880, section // serializeHeader writes an OpenPGP packet header to w. See RFC 4880, section
// 4.2. // 4.2.
func serialiseHeader(w io.Writer, ptype packetType, length int) (err os.Error) { func serializeHeader(w io.Writer, ptype packetType, length int) (err os.Error) {
var buf [6]byte var buf [6]byte
var n int var n int
...@@ -371,7 +371,7 @@ func (cipher CipherFunction) new(key []byte) (block cipher.Block) { ...@@ -371,7 +371,7 @@ func (cipher CipherFunction) new(key []byte) (block cipher.Block) {
// readMPI reads a big integer from r. The bit length returned is the bit // readMPI reads a big integer from r. The bit length returned is the bit
// length that was specified in r. This is preserved so that the integer can be // length that was specified in r. This is preserved so that the integer can be
// reserialised exactly. // reserialized exactly.
func readMPI(r io.Reader) (mpi []byte, bitLength uint16, err os.Error) { func readMPI(r io.Reader) (mpi []byte, bitLength uint16, err os.Error) {
var buf [2]byte var buf [2]byte
_, err = readFull(r, buf[0:]) _, err = readFull(r, buf[0:])
...@@ -385,7 +385,7 @@ func readMPI(r io.Reader) (mpi []byte, bitLength uint16, err os.Error) { ...@@ -385,7 +385,7 @@ func readMPI(r io.Reader) (mpi []byte, bitLength uint16, err os.Error) {
return return
} }
// writeMPI serialises a big integer to r. // writeMPI serializes a big integer to r.
func writeMPI(w io.Writer, bitLength uint16, mpiBytes []byte) (err os.Error) { func writeMPI(w io.Writer, bitLength uint16, mpiBytes []byte) (err os.Error) {
_, err = w.Write([]byte{byte(bitLength >> 8), byte(bitLength)}) _, err = w.Write([]byte{byte(bitLength >> 8), byte(bitLength)})
if err == nil { if err == nil {
......
...@@ -191,13 +191,13 @@ func TestReadHeader(t *testing.T) { ...@@ -191,13 +191,13 @@ func TestReadHeader(t *testing.T) {
} }
} }
func TestSerialiseHeader(t *testing.T) { func TestSerializeHeader(t *testing.T) {
tag := packetTypePublicKey tag := packetTypePublicKey
lengths := []int{0, 1, 2, 64, 192, 193, 8000, 8384, 8385, 10000} lengths := []int{0, 1, 2, 64, 192, 193, 8000, 8384, 8385, 10000}
for _, length := range lengths { for _, length := range lengths {
buf := bytes.NewBuffer(nil) buf := bytes.NewBuffer(nil)
serialiseHeader(buf, tag, length) serializeHeader(buf, tag, length)
tag2, length2, _, err := readHeader(buf) tag2, length2, _, err := readHeader(buf)
if err != nil { if err != nil {
t.Errorf("length %d, err: %s", length, err) t.Errorf("length %d, err: %s", length, err)
......
...@@ -241,7 +241,7 @@ func (pk *PublicKey) VerifyUserIdSignature(id string, sig *Signature) (err os.Er ...@@ -241,7 +241,7 @@ func (pk *PublicKey) VerifyUserIdSignature(id string, sig *Signature) (err os.Er
// A parsedMPI is used to store the contents of a big integer, along with the // A parsedMPI is used to store the contents of a big integer, along with the
// bit length that was specified in the original input. This allows the MPI to // bit length that was specified in the original input. This allows the MPI to
// be reserialised exactly. // be reserialized exactly.
type parsedMPI struct { type parsedMPI struct {
bytes []byte bytes []byte
bitLength uint16 bitLength uint16
......
...@@ -316,8 +316,8 @@ func subpacketLengthLength(length int) int { ...@@ -316,8 +316,8 @@ func subpacketLengthLength(length int) int {
return 5 return 5
} }
// serialiseSubpacketLength marshals the given length into to. // serializeSubpacketLength marshals the given length into to.
func serialiseSubpacketLength(to []byte, length int) int { func serializeSubpacketLength(to []byte, length int) int {
if length < 192 { if length < 192 {
to[0] = byte(length) to[0] = byte(length)
return 1 return 1
...@@ -336,7 +336,7 @@ func serialiseSubpacketLength(to []byte, length int) int { ...@@ -336,7 +336,7 @@ func serialiseSubpacketLength(to []byte, length int) int {
return 5 return 5
} }
// subpacketsLength returns the serialised length, in bytes, of the given // subpacketsLength returns the serialized length, in bytes, of the given
// subpackets. // subpackets.
func subpacketsLength(subpackets []outputSubpacket, hashed bool) (length int) { func subpacketsLength(subpackets []outputSubpacket, hashed bool) (length int) {
for _, subpacket := range subpackets { for _, subpacket := range subpackets {
...@@ -349,11 +349,11 @@ func subpacketsLength(subpackets []outputSubpacket, hashed bool) (length int) { ...@@ -349,11 +349,11 @@ func subpacketsLength(subpackets []outputSubpacket, hashed bool) (length int) {
return return
} }
// serialiseSubpackets marshals the given subpackets into to. // serializeSubpackets marshals the given subpackets into to.
func serialiseSubpackets(to []byte, subpackets []outputSubpacket, hashed bool) { func serializeSubpackets(to []byte, subpackets []outputSubpacket, hashed bool) {
for _, subpacket := range subpackets { for _, subpacket := range subpackets {
if subpacket.hashed == hashed { if subpacket.hashed == hashed {
n := serialiseSubpacketLength(to, len(subpacket.contents)+1) n := serializeSubpacketLength(to, len(subpacket.contents)+1)
to[n] = byte(subpacket.subpacketType) to[n] = byte(subpacket.subpacketType)
to = to[1+n:] to = to[1+n:]
n = copy(to, subpacket.contents) n = copy(to, subpacket.contents)
...@@ -381,7 +381,7 @@ func (sig *Signature) buildHashSuffix() (err os.Error) { ...@@ -381,7 +381,7 @@ func (sig *Signature) buildHashSuffix() (err os.Error) {
} }
sig.HashSuffix[4] = byte(hashedSubpacketsLen >> 8) sig.HashSuffix[4] = byte(hashedSubpacketsLen >> 8)
sig.HashSuffix[5] = byte(hashedSubpacketsLen) sig.HashSuffix[5] = byte(hashedSubpacketsLen)
serialiseSubpackets(sig.HashSuffix[6:l], sig.outSubpackets, true) serializeSubpackets(sig.HashSuffix[6:l], sig.outSubpackets, true)
trailer := sig.HashSuffix[l:] trailer := sig.HashSuffix[l:]
trailer[0] = 4 trailer[0] = 4
trailer[1] = 0xff trailer[1] = 0xff
...@@ -417,7 +417,7 @@ func (sig *Signature) Serialize(w io.Writer) (err os.Error) { ...@@ -417,7 +417,7 @@ func (sig *Signature) Serialize(w io.Writer) (err os.Error) {
length := len(sig.HashSuffix) - 6 /* trailer not included */ + length := len(sig.HashSuffix) - 6 /* trailer not included */ +
2 /* length of unhashed subpackets */ + unhashedSubpacketsLen + 2 /* length of unhashed subpackets */ + unhashedSubpacketsLen +
2 /* hash tag */ + 2 /* length of signature MPI */ + len(sig.Signature) 2 /* hash tag */ + 2 /* length of signature MPI */ + len(sig.Signature)
err = serialiseHeader(w, packetTypeSignature, length) err = serializeHeader(w, packetTypeSignature, length)
if err != nil { if err != nil {
return return
} }
...@@ -430,7 +430,7 @@ func (sig *Signature) Serialize(w io.Writer) (err os.Error) { ...@@ -430,7 +430,7 @@ func (sig *Signature) Serialize(w io.Writer) (err os.Error) {
unhashedSubpackets := make([]byte, 2+unhashedSubpacketsLen) unhashedSubpackets := make([]byte, 2+unhashedSubpacketsLen)
unhashedSubpackets[0] = byte(unhashedSubpacketsLen >> 8) unhashedSubpackets[0] = byte(unhashedSubpacketsLen >> 8)
unhashedSubpackets[1] = byte(unhashedSubpacketsLen) unhashedSubpackets[1] = byte(unhashedSubpacketsLen)
serialiseSubpackets(unhashedSubpackets[2:], sig.outSubpackets, false) serializeSubpackets(unhashedSubpackets[2:], sig.outSubpackets, false)
_, err = w.Write(unhashedSubpackets) _, err = w.Write(unhashedSubpackets)
if err != nil { if err != nil {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment