Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(21)

Delta Between Two Patch Sets: src/pkg/crypto/openpgp/packet/public_key_test.go

Issue 3973054: code review 3973054: crypto/openpgp/packet: add public key support (Closed)
Left Patch Set: Created 14 years, 1 month ago
Right Patch Set: diff -r 609e4b01e938 https://go.googlecode.com/hg/ Created 14 years, 1 month ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Right: Side by side diff | Download
« no previous file with change/comment | « src/pkg/crypto/openpgp/packet/public_key.go ('k') | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
(no file at all)
1 // Copyright 2011 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
4
5 package packet
6
7 import (
8 "bytes"
9 "encoding/hex"
10 "testing"
11 )
12
13 var pubKeyTests = []struct {
14 hexData string
15 hexFingerprint string
16 creationTime uint32
17 pubKeyAlgo PublicKeyAlgorithm
18 keyId uint64
19 }{
20 {rsaPkDataHex, rsaFingerprintHex, 0x4d3c5c10, PubKeyAlgoRSA, 0xa34d7e18c 20c31bb},
21 {dsaPkDataHex, dsaFingerprintHex, 0x4d432f89, PubKeyAlgoDSA, 0x8e8fbe540 62f19ed},
22 }
23
24 func TestPublicKeyRead(t *testing.T) {
25 for i, test := range pubKeyTests {
26 packet, err := Read(readerFromHex(test.hexData))
27 if err != nil {
28 t.Errorf("#%d: Read error: %s", i, err)
29 return
30 }
31 pk, ok := packet.(*PublicKey)
32 if !ok {
33 t.Errorf("#%d: failed to parse, got: %#v", i, packet)
34 return
35 }
36 if pk.PubKeyAlgo != test.pubKeyAlgo {
37 t.Errorf("#%d: bad public key algorithm got:%x want:%x", i, pk.PubKeyAlgo, test.pubKeyAlgo)
38 }
39 if pk.CreationTime != test.creationTime {
40 t.Errorf("#%d: bad creation time got:%x want:%x", i, pk. CreationTime, test.creationTime)
41 }
42 expectedFingerprint, _ := hex.DecodeString(test.hexFingerprint)
43 if !bytes.Equal(expectedFingerprint, pk.Fingerprint[:]) {
44 t.Errorf("#%d: bad fingerprint got:%x want:%x", i, pk.Fi ngerprint[:], expectedFingerprint)
45 }
46 if pk.KeyId != test.keyId {
47 t.Errorf("#%d: bad keyid got:%x want:%x", i, pk.KeyId, t est.keyId)
48 }
49 }
50 }
51
52 const rsaFingerprintHex = "5fb74b1d03b1e3cb31bc2f8aa34d7e18c20c31bb"
53
54 const rsaPkDataHex = "988d044d3c5c10010400b1d13382944bd5aba23a4312968b5095d14f94 7f600eb478e14a6fcb16b0e0cac764884909c020bc495cfcc39a935387c661507bdb236a0612fb58 2cac3af9b29cc2c8c70090616c41b662f4da4c1201e195472eb7f4ae1ccbcbf9940fe21d985e379a 5563dde5b9a23d35f1cfaa5790da3b79db26f23695107bfaca8e7b5bcd0011010001"
55
56 const dsaFingerprintHex = "eece4c094db002103714c63c8e8fbe54062f19ed"
57
58 const dsaPkDataHex = "9901a2044d432f89110400cd581334f0d7a1e1bdc8b9d6d8c0baf68793 632735d2bb0903224cbaa1dfbf35a60ee7a13b92643421e1eb41aa8d79bea19a115a677f6b8ba3c7 818ce53a6c2a24a1608bd8b8d6e55c5090cbde09dd26e356267465ae25e69ec8bdd57c7bbb2623e4 d73336f73a0a9098f7f16da2e25252130fd694c0e8070c55a812a423ae7f00a0ebf50e70c2f19c35 20a551bd4b08d30f23530d3d03ff7d0bf4a53a64a09dc5e6e6e35854b7d70c882b0c60293401958b 1bd9e40abec3ea05ba87cf64899299d4bd6aa7f459c201d3fbbd6c82004bdc5e8a9eb8082d12054c c90fa9d4ec251a843236a588bf49552441817436c4f43326966fe85447d4e6d0acf8fa1ef0f01473 0770603ad7634c3088dc52501c237328417c31c89ed70400b2f1a98b0bf42f11fefc430704bebbaa 41d9f355600c3facee1e490f64208e0e094ea55e3a598a219a58500bf78ac677b670a14f4e47e9cf 8eab4f368cc1ddcaa18cc59309d4cc62dd4f680e73e6cc3e1ce87a84d0925efbcb26c575c093fc42 eecf45135fabf6403a25c2016e1774c0484e440a18319072c617cc97ac0a3bb0"
LEFTRIGHT

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b