1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
|
package Crypt::OpenPGP::Words;
use strict;
use Crypt::OpenPGP::ErrorHandler;
use base qw( Crypt::OpenPGP::ErrorHandler );
## Biometric word lists as defined in manual for
## PGPFreeware for Windows 6.5.1, Appendix D
## Code based on Mike Dillon's PGPWords.pm
{
my @WORDS;
sub encode_hex { $_[0]->encode(pack 'H*', $_[1]) }
sub encode {
my $class = shift;
my($data) = @_;
my $toggle = 1;
map { $WORDS[$toggle = !$toggle][$_] } unpack 'C*', $data;
}
@WORDS = (
## Two-syllable words for encoding odd bytes
[ qw(
aardvark absurd accrue acme
adrift adult afflict ahead
aimless Algol allow alone
ammo ancient apple artist
assume Athens atlas Aztec
baboon backfield backward banjo
beaming bedlamp beehive beeswax
befriend Belfast berserk billiard
bison blackjack blockade blowtorch
bluebird bombast bookshelf brackish
breadline breakup brickyard briefcase
Burbank button buzzard cement
chairlift chatter checkup chisel
choking chopper Christmas clamshell
classic classroom cleanup clockwork
cobra commence concert cowbell
crackdown cranky crowfoot crucial
crumpled crusade cubic dashboard
deadbolt deckhand dogsled dragnet
drainage dreadful drifter dropper
drumbeat drunken Dupont dwelling
eating edict egghead eightball
endorse endow enlist erase
escape exceed eyeglass eyetooth
facial fallout flagpole flatfoot
flytrap fracture framework freedom
frighten gazelle Geiger glitter
glucose goggles goldfish gremlin
guidance hamlet highchair hockey
indoors indulge inverse involve
island jawbone keyboard kickoff
kiwi klaxon locale lockup
merit minnow miser Mohawk
mural music necklace Neptune
newborn nightbird Oakland obtuse
offload optic orca payday
peachy pheasant physique playhouse
Pluto preclude prefer preshrunk
printer prowler pupil puppy
python quadrant quiver quota
ragtime ratchet rebirth reform
regain reindeer rematch repay
retouch revenge reward rhythm
ribcage ringbolt robust rocker
ruffled sailboat sawdust scallion
scenic scorecard Scotland seabird
select sentence shadow shamrock
showgirl skullcap skydive slingshot
slowdown snapline snapshot snowcap
snowslide solo southward soybean
spaniel spearhead spellbind spheroid
spigot spindle spyglass stagehand
stagnate stairway standard stapler
steamship sterling stockman stopwatch
stormy sugar surmount suspense
sweatband swelter tactics talon
tapeworm tempest tiger tissue
tonic topmost tracker transit
trauma treadmill Trojan trouble
tumor tunnel tycoon uncut
unearth unwind uproot upset
upshot vapor village virus
Vulcan waffle wallet watchword
wayside willow woodlark Zulu
) ],
## Three-syllable words for encoding even bytes
[ qw(
adroitness adviser aftermath aggregate
alkali almighty amulet amusement
antenna applicant Apollo armistice
article asteroid Atlantic atmosphere
autopsy Babylon backwater barbecue
belowground bifocals bodyguard bookseller
borderline bottomless Bradbury bravado
Brazilian breakaway Burlington businessman
butterfat Camelot candidate cannonball
Capricorn caravan caretaker celebrate
cellulose certify chambermaid Cherokee
Chicago clergyman coherence combustion
commando company component concurrent
confidence conformist congregate consensus
consulting corporate corrosion councilman
crossover crucifix cumbersome customer
Dakota decadence December decimal
designing detector detergent determine
dictator dinosaur direction disable
disbelief disruptive distortion document
embezzle enchanting enrollment enterprise
equation equipment escapade Eskimo
everyday examine existence exodus
fascinate filament finicky forever
fortitude frequency gadgetry Galveston
getaway glossary gossamer graduate
gravity guitarist hamburger Hamilton
handiwork hazardous headwaters hemisphere
hesitate hideaway holiness hurricane
hydraulic impartial impetus inception
indigo inertia infancy inferno
informant insincere insurgent integrate
intention inventive Istanbul Jamaica
Jupiter leprosy letterhead liberty
maritime matchmaker maverick Medusa
megaton microscope microwave midsummer
millionaire miracle misnomer molasses
molecule Montana monument mosquito
narrative nebula newsletter Norwegian
October Ohio onlooker opulent
Orlando outfielder Pacific pandemic
Pandora paperweight paragon paragraph
paramount passenger pedigree Pegasus
penetrate perceptive performance pharmacy
phonetic photograph pioneer pocketful
politeness positive potato processor
provincial proximate puberty publisher
pyramid quantity racketeer rebellion
recipe recover repellent replica
reproduce resistor responsive retraction
retrieval retrospect revenue revival
revolver sandalwood sardonic Saturday
savagery scavenger sensation sociable
souvenir specialist speculate stethoscope
stupendous supportive surrender suspicious
sympathy tambourine telephone therapist
tobacco tolerance tomorrow torpedo
tradition travesty trombonist truncated
typewriter ultimate undaunted underfoot
unicorn unify universe unravel
upcoming vacancy vagabond vertigo
Virginia visitor vocalist voyager
warranty Waterloo whimsical Wichita
Wilmington Wyoming yesteryear Yucatan
) ]
);
}
1;
__END__
=head1 NAME
Crypt::OpenPGP::Words - Create English-word encodings
=head1 SYNOPSIS
use Crypt::OpenPGP::Words;
my $cert = Crypt::OpenPGP::Certificate->new;
my @words = Crypt::OpenPGP::Words->encode( $cert->fingerprint );
=head1 DESCRIPTION
I<Crypt::OpenPGP::Words> provides routines to convert either octet or
hexadecimal strings into a list of English words, using the same
algorithm and biometric word lists as used in PGP (see
I<AUTHOR & COPYRIGHTS> for source of word lists).
In PGP this is often used for creating memorable fingerprints, the idea
being that it is easier to associate a list of words with one's key
than a string of hex digits. See the I<fingerprint_words> method in
I<Crypt::OpenPGP::Certificate> for an interface to word fingerprints.
=head1 USAGE
=head2 Crypt::OpenPGP::Words->encode( $octet_str )
Given an octet string I<$octet_str>, encodes that string into a list of
English words.
The encoding is performed by splitting the string into octets; the list
of octets is then iterated over. There are two lists of words, 256 words
each. Two-syllable words are used for encoding odd iterations through
the loop; three-syllable words for even iterations. The word list is
formed by treating each octet as an index into the appropriate word list
(two- or three-syllable), then adding the word at that index to the list.
Returns the list of words.
=head2 Crypt::OpenPGP::Words->encode_hex( $hex_str )
Performs the exact same encoding as I<encode>; I<$hex_str>, a string
of hexadecimal digits, is first transformed into a string of octets,
then passed to I<encode>.
Returns the list of words.
=head1 AUTHOR & COPYRIGHTS
Based on PGPWords.pm by Mike Dillon. Biometric word lists as defined in
manual for PGPFreeware for Windows 6.5.1, Appendix D
Please see the Crypt::OpenPGP manpage for author, copyright, and
license information.
=cut
|