2 /** \ingroup rpmio signature
4 * Routines to handle RFC-2440 detached signatures.
8 #include "rpmio_internal.h"
12 /*@access pgpDigParams @*/
15 static int _debug = 0;
18 static int _print = 0;
20 /*@unchecked@*/ /*@null@*/
21 static pgpDig _dig = NULL;
23 /*@unchecked@*/ /*@null@*/
24 static pgpDigParams _digp = NULL;
27 /* This is the unarmored RPM-GPG-KEY public key. */
28 const char * redhatPubKeyDSA = "\
29 mQGiBDfqVDgRBADBKr3Bl6PO8BQ0H8sJoD6p9U7Yyl7pjtZqioviPwXP+DCWd4u8\n\
30 HQzcxAZ57m8ssA1LK1Fx93coJhDzM130+p5BG9mYSWShLabR3N1KXdXQYYcowTOM\n\
31 GxdwYRGr1Spw8QydLhjVfU1VSl4xt6bupPbWJbyjkg5Z3P7BlUOUJmrx3wCgobNV\n\
32 EDGaWYJcch5z5B1of/41G8kEAKii6q7Gu/vhXXnLS6m15oNnPVybyngiw/23dKjS\n\
33 ZVG7rKANEK2mxg1VB+vc/uUc4k49UxJJfCZg1gu1sPFV3GSa+Y/7jsiLktQvCiLP\n\
34 lncQt1dV+ENmHR5BdIDPWDzKBVbgWnSDnqQ6KrZ7T6AlZ74VMpjGxxkWU6vV2xsW\n\
35 XCLPA/9P/vtImA8CZN3jxGgtK5GGtDNJ/cMhhuv5tnfwFg4b/VGo2Jr8mhLUqoIb\n\
36 E6zeGAmZbUpdckDco8D5fiFmqTf5+++pCEpJLJkkzel/32N2w4qzPrcRMCiBURES\n\
37 PjCLd4Y5rPoU8E4kOHc/4BuHN903tiCsCPloCrWsQZ7UdxfQ5LQiUmVkIEhhdCwg\n\
38 SW5jIDxzZWN1cml0eUByZWRoYXQuY29tPohVBBMRAgAVBQI36lQ4AwsKAwMVAwID\n\
39 FgIBAheAAAoJECGRgM3bQqYOsBQAnRVtg7B25Hm11PHcpa8FpeddKiq2AJ9aO8sB\n\
40 XmLDmPOEFI75mpTrKYHF6rkCDQQ36lRyEAgAokgI2xJ+3bZsk8jRA8ORIX8DH05U\n\
41 lMH27qFYzLbT6npXwXYIOtVn0K2/iMDj+oEB1Aa2au4OnddYaLWp06v3d+XyS0t+\n\
42 5ab2ZfIQzdh7wCwxqRkzR+/H5TLYbMG+hvtTdylfqIX0WEfoOXMtWEGSVwyUsnM3\n\
43 Jy3LOi48rQQSCKtCAUdV20FoIGWhwnb/gHU1BnmES6UdQujFBE6EANqPhp0coYoI\n\
44 hHJ2oIO8ujQItvvNaU88j/s/izQv5e7MXOgVSjKe/WX3s2JtB/tW7utpy12wh1J+\n\
45 JsFdbLV/t8CozUTpJgx5mVA3RKlxjTA+On+1IEUWioB+iVfT7Ov/0kcAzwADBQf9\n\
46 E4SKCWRand8K0XloMYgmipxMhJNnWDMLkokvbMNTUoNpSfRoQJ9EheXDxwMpTPwK\n\
47 ti/PYrrL2J11P2ed0x7zm8v3gLrY0cue1iSba+8glY+p31ZPOr5ogaJw7ZARgoS8\n\
48 BwjyRymXQp+8Dete0TELKOL2/itDOPGHW07SsVWOR6cmX4VlRRcWB5KejaNvdrE5\n\
49 4XFtOd04NMgWI63uqZc4zkRa+kwEZtmbz3tHSdRCCE+Y7YVP6IUf/w6YPQFQriWY\n\
50 FiA6fD10eB+BlIUqIw80VgjsBKmCwvKkn4jg8kibXgj4/TzQSx77uYokw1EqQ2wk\n\
51 OZoaEtcubsNMquuLCMWijYhGBBgRAgAGBQI36lRyAAoJECGRgM3bQqYOhyYAnj7h\n\
52 VDY/FJAGqmtZpwVp9IlitW5tAJ4xQApr/jNFZCTksnI+4O1765F7tA==\n\
55 /* This is the unarmored RPM-PGP-KEY public key. */
56 const char * redhatPubKeyRSA = "\
57 mQCNAzEpXjUAAAEEAKG4/V9oUSiDc9wIge6Bmg6erDGCLzmFyioAho8kDIJSrcmi\n\
58 F9qTdPq+fj726pgW1iSb0Y7syZn9Y2lgQm5HkPODfNi8eWyTFSxbr8ygosLRClTP\n\
59 xqHVhtInGrfZNLoSpv1LdWOme0yOpOQJnghdOMzKXpgf5g84vaUg6PHLopv5AAUR\n\
60 tCpSZWQgSGF0IFNvZnR3YXJlLCBJbmMuIDxyZWRoYXRAcmVkaGF0LmNvbT6JAJUD\n\
61 BRAyA5tUoyDApfg4JKEBAUzSA/9QdcVsu955vVyZDk8uvOXWV0X3voT9B3aYMFvj\n\
62 UNHUD6F1VFruwQHVKbGJEq1o5MOA6OXKR3vJZStXEMF47TWXJfQaflgl8ywZTH5W\n\
63 +eMlKau6Nr0labUV3lmsAE4Vsgu8NCkzIrp2wNVbeW2ZAXtrKswV+refLquUhp7l\n\
64 wMpH9IkAdQMFEDGttkRNdXhbO1TgGQEBAGoC/j6C22PqXIyqZc6fG6J6Jl/T5kFG\n\
65 xH1pKIzua5WCDDugAgnuOJgywa4pegT4UqwEZiMTAlwT6dmG1CXgKB+5V7lnCjDc\n\
66 JZLni0iztoe08ig6fJrjNGXljf7KYXzgwBftQokAlQMFEDMQzo2MRVM9rfPulQEB\n\
67 pLoD/1/MWv3u0Paiu14XRvDrBaJ7BmG2/48bA5vKOzpvvoNRO95YS7ZEtqErXA7Y\n\
68 DRO8+C8f6PAILMk7kCk4lNMscS/ZRzu5+J8cv4ejsFvxgJBBU3Zgp8AWdWOpvZ0I\n\
69 wW//HoDUGhOxlEtymljIMFBkj4SysHWhCBUfA9Xy86kouTJQiQCVAwUQMxDOQ50a\n\
70 feTWLUSJAQFnYQQAkt9nhMTeioREB1DvJt+vsFyOj//o3ThqK5ySEP3dgj62iaQp\n\
71 JrBmAe5XZPw25C/TXAf+x27H8h2QbKgq49VtsElFexc6wO+uq85fAPDdyE+2XyNE\n\
72 njGZkY/TP2F/jTB0sAwJO+xFCHmSYkcBjzxK/2LMD+O7rwp2UCUhhl9QhhqJAJUD\n\
73 BRAx5na6pSDo8cuim/kBARmjA/4lDVnV2h9KiNabp9oE38wmGgu5m5XgUHW8L6du\n\
74 iQDnwO5IgXN2vDpKGxbgtwv6iYYmGd8IRQ66uJvOsxSv3OR7J7LkCHuI2b/s0AZn\n\
75 c79DZaJ2ChUCZlbNQBMeEdrFWif9NopY+d5+2tby1onu9XOFMMvomxL3NhctElYR\n\
76 HC8Xw4kAlQMFEDHmdTtURTdEKY1MpQEBEtEEAMZbp1ZFrjiHkj2aLFC1S8dGRbSH\n\
77 GUdnLP9qLPFgmWekp9E0o8ZztALGVdqPfPF3N/JJ+AL4IMrfojd7+eZKw36Mdvtg\n\
78 dPI+Oz4sxHDbDynZ2qspD9Om5yYuxuz/Xq+9nO2IlsAnEYw3ag3cxat0kvxpOPRe\n\
79 Yy+vFpgfDNizr3MgiQBVAwUQMXNMXCjtrosVMemRAQEDnwH7BsJrnnh91nI54LAK\n\
80 Gcq3pr8ld0PAtWJmNRGQvUlpEMXUSnu59j2P1ogPNjL3PqKdVxk5Jqgcr8TPQMf3\n\
81 V4fqXokAlQMFEDFy+8YiEmsRQ3LyzQEB+TwD/03QDslXLg5F3zj4zf0yI6ikT0be\n\
82 5OhZv2pnkb80qgdHzFRxBOYmSoueRKdQJASd8F9ue4b3bmf/Y7ikiY0DblvxcXB2\n\
83 sz1Pu8i2Zn9u8SKuxNIoVvM8/STRVkgPfvL5QjAWMHT9Wvg81XcI2yXJzrt/2f2g\n\
84 mNpWIvVOOT85rVPIiQCVAwUQMVPRlBlzviMjNHElAQG1nwP/fpVX6nKRWJCSFeB7\n\
85 leZ4lb+y1uMsMVv0n7agjJVw13SXaA267y7VWCBlnhsCemxEugqEIkI4lu/1mgtw\n\
86 WPWSE0BOIVjj0AA8zp2T0H3ZCCMbiFAFJ1P2Gq2rKr8QrOb/08oH1lEzyz0j/jKh\n\
87 qiXAxdlB1wojQB6yLbHvTIe3rZGJAHUDBRAxKetfzauiKSJ6LJEBAed/AvsEiGgj\n\
88 TQzhsZcUuRNrQpV0cDGH9Mpril7P7K7yFIzju8biB+Cu6nEknSOHlMLl8usObVlk\n\
89 d8Wf14soHC7SjItiGSKtI8JhauzBJPl6fDDeyHGsJKo9f9adKeBMCipCFOuJAJUD\n\
90 BRAxKeqWRHFTaIK/x+0BAY6eA/4m5X4gs1UwOUIRnljo9a0cVs6ITL554J9vSCYH\n\
91 Zzd87kFwdf5W1Vd82HIkRzcr6cp33E3IDkRzaQCMVw2me7HePP7+4Ry2q3EeZMbm\n\
92 NE++VzkxjikzpRb2+F5nGB2UdsElkgbXinswebiuOwOrocLbz6JFdDsJPcT5gVfi\n\
97 struct pgpValTbl_s pgpSigTypeTbl[] = {
98 { PGPSIGTYPE_BINARY, "Binary document signature" },
99 { PGPSIGTYPE_TEXT, "Text document signature" },
100 { PGPSIGTYPE_STANDALONE, "Standalone signature" },
101 { PGPSIGTYPE_GENERIC_CERT, "Generic certification of a User ID and Public Key" },
102 { PGPSIGTYPE_PERSONA_CERT, "Persona certification of a User ID and Public Key" },
103 { PGPSIGTYPE_CASUAL_CERT, "Casual certification of a User ID and Public Key" },
104 { PGPSIGTYPE_POSITIVE_CERT, "Positive certification of a User ID and Public Key" },
105 { PGPSIGTYPE_SUBKEY_BINDING,"Subkey Binding Signature" },
106 { PGPSIGTYPE_SIGNED_KEY, "Signature directly on a key" },
107 { PGPSIGTYPE_KEY_REVOKE, "Key revocation signature" },
108 { PGPSIGTYPE_SUBKEY_REVOKE, "Subkey revocation signature" },
109 { PGPSIGTYPE_CERT_REVOKE, "Certification revocation signature" },
110 { PGPSIGTYPE_TIMESTAMP, "Timestamp signature" },
111 { -1, "Unknown signature type" },
114 struct pgpValTbl_s pgpPubkeyTbl[] = {
115 { PGPPUBKEYALGO_RSA, "RSA" },
116 { PGPPUBKEYALGO_RSA_ENCRYPT,"RSA(Encrypt-Only)" },
117 { PGPPUBKEYALGO_RSA_SIGN, "RSA(Sign-Only)" },
118 { PGPPUBKEYALGO_ELGAMAL_ENCRYPT,"Elgamal(Encrypt-Only)" },
119 { PGPPUBKEYALGO_DSA, "DSA" },
120 { PGPPUBKEYALGO_EC, "Elliptic Curve" },
121 { PGPPUBKEYALGO_ECDSA, "ECDSA" },
122 { PGPPUBKEYALGO_ELGAMAL, "Elgamal" },
123 { PGPPUBKEYALGO_DH, "Diffie-Hellman (X9.42)" },
124 { -1, "Unknown public key algorithm" },
127 struct pgpValTbl_s pgpSymkeyTbl[] = {
128 { PGPSYMKEYALGO_PLAINTEXT, "Plaintext" },
129 { PGPSYMKEYALGO_IDEA, "IDEA" },
130 { PGPSYMKEYALGO_TRIPLE_DES, "3DES" },
131 { PGPSYMKEYALGO_CAST5, "CAST5" },
132 { PGPSYMKEYALGO_BLOWFISH, "BLOWFISH" },
133 { PGPSYMKEYALGO_SAFER, "SAFER" },
134 { PGPSYMKEYALGO_DES_SK, "DES/SK" },
135 { PGPSYMKEYALGO_AES_128, "AES(128-bit key)" },
136 { PGPSYMKEYALGO_AES_192, "AES(192-bit key)" },
137 { PGPSYMKEYALGO_AES_256, "AES(256-bit key)" },
138 { PGPSYMKEYALGO_TWOFISH, "TWOFISH" },
139 { -1, "Unknown symmetric key algorithm" },
142 struct pgpValTbl_s pgpCompressionTbl[] = {
143 { PGPCOMPRESSALGO_NONE, "Uncompressed" },
144 { PGPCOMPRESSALGO_ZIP, "ZIP" },
145 { PGPCOMPRESSALGO_ZLIB, "ZLIB" },
146 { -1, "Unknown compression algorithm" },
149 struct pgpValTbl_s pgpHashTbl[] = {
150 { PGPHASHALGO_MD5, "MD5" },
151 { PGPHASHALGO_SHA1, "SHA1" },
152 { PGPHASHALGO_RIPEMD160, "RIPEMD160" },
153 { PGPHASHALGO_MD2, "MD2" },
154 { PGPHASHALGO_TIGER192, "TIGER192" },
155 { PGPHASHALGO_HAVAL_5_160, "HAVAL-5-160" },
156 { -1, "Unknown hash algorithm" },
159 /*@-exportlocal -exportheadervar@*/
160 /*@observer@*/ /*@unchecked@*/
161 struct pgpValTbl_s pgpKeyServerPrefsTbl[] = {
162 { 0x80, "No-modify" },
163 { -1, "Unknown key server preference" },
165 /*@=exportlocal =exportheadervar@*/
167 struct pgpValTbl_s pgpSubTypeTbl[] = {
168 { PGPSUBTYPE_SIG_CREATE_TIME,"signature creation time" },
169 { PGPSUBTYPE_SIG_EXPIRE_TIME,"signature expiration time" },
170 { PGPSUBTYPE_EXPORTABLE_CERT,"exportable certification" },
171 { PGPSUBTYPE_TRUST_SIG, "trust signature" },
172 { PGPSUBTYPE_REGEX, "regular expression" },
173 { PGPSUBTYPE_REVOCABLE, "revocable" },
174 { PGPSUBTYPE_KEY_EXPIRE_TIME,"key expiration time" },
175 { PGPSUBTYPE_BACKWARD_COMPAT,"placeholder for backward compatibility" },
176 { PGPSUBTYPE_PREFER_SYMKEY, "preferred symmetric algorithms" },
177 { PGPSUBTYPE_REVOKE_KEY, "revocation key" },
178 { PGPSUBTYPE_ISSUER_KEYID, "issuer key ID" },
179 { PGPSUBTYPE_NOTATION, "notation data" },
180 { PGPSUBTYPE_PREFER_HASH, "preferred hash algorithms" },
181 { PGPSUBTYPE_PREFER_COMPRESS,"preferred compression algorithms" },
182 { PGPSUBTYPE_KEYSERVER_PREFERS,"key server preferences" },
183 { PGPSUBTYPE_PREFER_KEYSERVER,"preferred key server" },
184 { PGPSUBTYPE_PRIMARY_USERID,"primary user id" },
185 { PGPSUBTYPE_POLICY_URL, "policy URL" },
186 { PGPSUBTYPE_KEY_FLAGS, "key flags" },
187 { PGPSUBTYPE_SIGNER_USERID, "signer's user id" },
188 { PGPSUBTYPE_REVOKE_REASON, "reason for revocation" },
189 { PGPSUBTYPE_INTERNAL_100, "internal subpkt type 100" },
190 { PGPSUBTYPE_INTERNAL_101, "internal subpkt type 101" },
191 { PGPSUBTYPE_INTERNAL_102, "internal subpkt type 102" },
192 { PGPSUBTYPE_INTERNAL_103, "internal subpkt type 103" },
193 { PGPSUBTYPE_INTERNAL_104, "internal subpkt type 104" },
194 { PGPSUBTYPE_INTERNAL_105, "internal subpkt type 105" },
195 { PGPSUBTYPE_INTERNAL_106, "internal subpkt type 106" },
196 { PGPSUBTYPE_INTERNAL_107, "internal subpkt type 107" },
197 { PGPSUBTYPE_INTERNAL_108, "internal subpkt type 108" },
198 { PGPSUBTYPE_INTERNAL_109, "internal subpkt type 109" },
199 { PGPSUBTYPE_INTERNAL_110, "internal subpkt type 110" },
200 { -1, "Unknown signature subkey type" },
203 struct pgpValTbl_s pgpTagTbl[] = {
204 { PGPTAG_PUBLIC_SESSION_KEY,"Public-Key Encrypted Session Key" },
205 { PGPTAG_SIGNATURE, "Signature" },
206 { PGPTAG_SYMMETRIC_SESSION_KEY,"Symmetric-Key Encrypted Session Key" },
207 { PGPTAG_ONEPASS_SIGNATURE, "One-Pass Signature" },
208 { PGPTAG_SECRET_KEY, "Secret Key" },
209 { PGPTAG_PUBLIC_KEY, "Public Key" },
210 { PGPTAG_SECRET_SUBKEY, "Secret Subkey" },
211 { PGPTAG_COMPRESSED_DATA, "Compressed Data" },
212 { PGPTAG_SYMMETRIC_DATA, "Symmetrically Encrypted Data" },
213 { PGPTAG_MARKER, "Marker" },
214 { PGPTAG_LITERAL_DATA, "Literal Data" },
215 { PGPTAG_TRUST, "Trust" },
216 { PGPTAG_USER_ID, "User ID" },
217 { PGPTAG_PUBLIC_SUBKEY, "Public Subkey" },
218 { PGPTAG_COMMENT_OLD, "Comment (from OpenPGP draft)" },
219 { PGPTAG_PHOTOID, "PGP's photo ID" },
220 { PGPTAG_ENCRYPTED_MDC, "Integrity protected encrypted data" },
221 { PGPTAG_MDC, "Manipulaion detection code packet" },
222 { PGPTAG_PRIVATE_60, "Private #60" },
223 { PGPTAG_COMMENT, "Comment" },
224 { PGPTAG_PRIVATE_62, "Private #62" },
225 { PGPTAG_CONTROL, "Control (GPG)" },
226 { -1, "Unknown packet tag" },
229 struct pgpValTbl_s pgpArmorTbl[] = {
230 { PGPARMOR_MESSAGE, "MESSAGE" },
231 { PGPARMOR_PUBKEY, "PUBLIC KEY BLOCK" },
232 { PGPARMOR_SIGNATURE, "SIGNATURE" },
233 { PGPARMOR_SIGNED_MESSAGE, "SIGNED MESSAGE" },
234 { PGPARMOR_FILE, "ARMORED FILE" },
235 { PGPARMOR_PRIVKEY, "PRIVATE KEY BLOCK" },
236 { PGPARMOR_SECKEY, "SECRET KEY BLOCK" },
237 { -1, "Unknown armor block" }
240 struct pgpValTbl_s pgpArmorKeyTbl[] = {
241 { PGPARMORKEY_VERSION, "Version: " },
242 { PGPARMORKEY_COMMENT, "Comment: " },
243 { PGPARMORKEY_MESSAGEID, "MessageID: " },
244 { PGPARMORKEY_HASH, "Hash: " },
245 { PGPARMORKEY_CHARSET, "Charset: " },
246 { -1, "Unknown armor key" }
250 * Wrapper to free(3), hides const compilation noise, permit NULL, return NULL.
251 * @param p memory to free
252 * @return NULL always
254 /*@unused@*/ static inline /*@null@*/ void *
255 _free(/*@only@*/ /*@null@*/ /*@out@*/ const void * p)
258 if (p != NULL) free((void *)p);
262 static void pgpPrtNL(void)
263 /*@globals fileSystem @*/
264 /*@modifies fileSystem @*/
267 fprintf(stderr, "\n");
270 static void pgpPrtInt(const char *pre, int i)
271 /*@globals fileSystem @*/
272 /*@modifies fileSystem @*/
276 fprintf(stderr, "%s", pre);
277 fprintf(stderr, " %d", i);
280 static void pgpPrtStr(const char *pre, const char *s)
281 /*@globals fileSystem @*/
282 /*@modifies fileSystem @*/
286 fprintf(stderr, "%s", pre);
287 fprintf(stderr, " %s", s);
290 static void pgpPrtHex(const char *pre, const byte *p, unsigned int plen)
291 /*@globals fileSystem @*/
292 /*@modifies fileSystem @*/
296 fprintf(stderr, "%s", pre);
297 fprintf(stderr, " %s", pgpHexStr(p, plen));
300 void pgpPrtVal(const char * pre, pgpValTbl vs, byte val)
301 /*@globals fileSystem @*/
302 /*@modifies fileSystem @*/
306 fprintf(stderr, "%s", pre);
307 fprintf(stderr, "%s(%u)", pgpValStr(vs, val), (unsigned)val);
312 /*@unused@*/ static /*@observer@*/
313 const char * pgpMpiHex(const byte *p)
316 static char prbuf[2048];
318 t = pgpHexCvt(t, p+2, pgpMpiLen(p)-2);
324 * @return 0 on success
326 static int pgpHexSet(const char * pre, int lbits,
327 /*@out@*/ mpnumber * mpn, const byte * p, const byte * pend)
328 /*@globals fileSystem @*/
329 /*@modifies mpn, fileSystem @*/
331 unsigned int mbits = pgpMpiBits(p);
337 if ((p + ((mbits+7) >> 3)) > pend)
340 nbits = (lbits > mbits ? lbits : mbits);
341 nbytes = ((nbits + 7) >> 3);
342 t = xmalloc(2*nbytes+1);
343 ix = 2 * ((nbits - mbits) >> 3);
346 fprintf(stderr, "*** mbits %u nbits %u nbytes %u t %p[%d] ix %u\n", mbits, nbits, nbytes, t, (2*nbytes+1), ix);
347 if (ix > 0) memset(t, (int)'0', ix);
348 strcpy(t+ix, pgpMpiHex(p));
350 fprintf(stderr, "*** %s %s\n", pre, t);
351 (void) mpnsethex(mpn, t);
353 if (_debug && _print)
354 fprintf(stderr, "\t %s ", pre), mpfprintln(stderr, mpn->size, mpn->data);
359 int pgpPrtSubType(const byte *h, unsigned int hlen, pgpSigType sigtype)
366 i = pgpLen(p, &plen);
370 pgpPrtVal(" ", pgpSubTypeTbl, p[0]);
372 case PGPSUBTYPE_PREFER_SYMKEY: /* preferred symmetric algorithms */
373 for (i = 1; i < plen; i++)
374 pgpPrtVal(" ", pgpSymkeyTbl, p[i]);
375 /*@switchbreak@*/ break;
376 case PGPSUBTYPE_PREFER_HASH: /* preferred hash algorithms */
377 for (i = 1; i < plen; i++)
378 pgpPrtVal(" ", pgpHashTbl, p[i]);
379 /*@switchbreak@*/ break;
380 case PGPSUBTYPE_PREFER_COMPRESS:/* preferred compression algorithms */
381 for (i = 1; i < plen; i++)
382 pgpPrtVal(" ", pgpCompressionTbl, p[i]);
383 /*@switchbreak@*/ break;
384 case PGPSUBTYPE_KEYSERVER_PREFERS:/* key server preferences */
385 for (i = 1; i < plen; i++)
386 pgpPrtVal(" ", pgpKeyServerPrefsTbl, p[i]);
387 /*@switchbreak@*/ break;
388 case PGPSUBTYPE_SIG_CREATE_TIME:
389 /*@-mods -mayaliasunique @*/
390 if (_digp && !(_digp->saved & PGPDIG_SAVED_TIME) &&
391 sigtype == PGPSIGTYPE_POSITIVE_CERT)
393 _digp->saved |= PGPDIG_SAVED_TIME;
394 memcpy(_digp->time, p+1, sizeof(_digp->time));
396 /*@=mods =mayaliasunique @*/
398 case PGPSUBTYPE_SIG_EXPIRE_TIME:
399 case PGPSUBTYPE_KEY_EXPIRE_TIME:
400 if ((plen - 1) == 4) {
401 time_t t = pgpGrab(p+1, plen-1);
403 fprintf(stderr, " %-24.24s(0x%08x)", ctime(&t), (unsigned)t);
405 pgpPrtHex("", p+1, plen-1);
406 /*@switchbreak@*/ break;
408 case PGPSUBTYPE_ISSUER_KEYID: /* issuer key ID */
409 /*@-mods -mayaliasunique @*/
410 if (_digp && !(_digp->saved & PGPDIG_SAVED_ID) &&
411 sigtype == PGPSIGTYPE_POSITIVE_CERT)
413 _digp->saved |= PGPDIG_SAVED_ID;
414 memcpy(_digp->signid, p+1, sizeof(_digp->signid));
416 /*@=mods =mayaliasunique @*/
418 case PGPSUBTYPE_EXPORTABLE_CERT:
419 case PGPSUBTYPE_TRUST_SIG:
420 case PGPSUBTYPE_REGEX:
421 case PGPSUBTYPE_REVOCABLE:
422 case PGPSUBTYPE_BACKWARD_COMPAT:
423 case PGPSUBTYPE_REVOKE_KEY:
424 case PGPSUBTYPE_NOTATION:
425 case PGPSUBTYPE_PREFER_KEYSERVER:
426 case PGPSUBTYPE_PRIMARY_USERID:
427 case PGPSUBTYPE_POLICY_URL:
428 case PGPSUBTYPE_KEY_FLAGS:
429 case PGPSUBTYPE_SIGNER_USERID:
430 case PGPSUBTYPE_REVOKE_REASON:
431 case PGPSUBTYPE_INTERNAL_100:
432 case PGPSUBTYPE_INTERNAL_101:
433 case PGPSUBTYPE_INTERNAL_102:
434 case PGPSUBTYPE_INTERNAL_103:
435 case PGPSUBTYPE_INTERNAL_104:
436 case PGPSUBTYPE_INTERNAL_105:
437 case PGPSUBTYPE_INTERNAL_106:
438 case PGPSUBTYPE_INTERNAL_107:
439 case PGPSUBTYPE_INTERNAL_108:
440 case PGPSUBTYPE_INTERNAL_109:
441 case PGPSUBTYPE_INTERNAL_110:
443 pgpPrtHex("", p+1, plen-1);
444 /*@switchbreak@*/ break;
453 /*@-varuse =readonlytrans @*/
454 /*@observer@*/ /*@unchecked@*/
455 static const char * pgpSigRSA[] = {
460 /*@observer@*/ /*@unchecked@*/
461 static const char * pgpSigDSA[] = {
466 /*@=varuse =readonlytrans @*/
468 static int pgpPrtSigParams(/*@unused@*/ pgpTag tag, byte pubkey_algo, byte sigtype,
469 const byte *p, const byte *h, unsigned int hlen)
470 /*@globals fileSystem @*/
471 /*@modifies fileSystem @*/
473 const byte * pend = h + hlen;
476 for (i = 0; p < pend; i++, p += pgpMpiLen(p)) {
477 if (pubkey_algo == PGPPUBKEYALGO_RSA) {
480 (sigtype == PGPSIGTYPE_BINARY || sigtype == PGPSIGTYPE_TEXT))
484 (void) mpnsethex(&_dig->c, pgpMpiHex(p));
485 if (_debug && _print)
486 fprintf(stderr, "\t m**d = "), mpfprintln(stderr, _dig->c.size, _dig->c.data);
487 /*@switchbreak@*/ break;
489 /*@switchbreak@*/ break;
492 pgpPrtStr("", pgpSigRSA[i]);
493 } else if (pubkey_algo == PGPPUBKEYALGO_DSA) {
496 (sigtype == PGPSIGTYPE_BINARY || sigtype == PGPSIGTYPE_TEXT))
502 xx = pgpHexSet(pgpSigDSA[i], 160, &_dig->r, p, pend);
503 /*@switchbreak@*/ break;
505 xx = pgpHexSet(pgpSigDSA[i], 160, &_dig->s, p, pend);
506 /*@switchbreak@*/ break;
509 /*@switchbreak@*/ break;
513 pgpPrtStr("", pgpSigDSA[i]);
516 fprintf(stderr, "%7d", i);
518 pgpPrtStr("", pgpMpiStr(p));
525 int pgpPrtSig(pgpTag tag, const byte *h, unsigned int hlen)
527 /*@modifies *_digp @*/
536 { pgpPktSigV3 v = (pgpPktSigV3)h;
542 pgpPrtVal("V3 ", pgpTagTbl, tag);
543 pgpPrtVal(" ", pgpPubkeyTbl, v->pubkey_algo);
544 pgpPrtVal(" ", pgpHashTbl, v->hash_algo);
545 pgpPrtVal(" ", pgpSigTypeTbl, v->sigtype);
547 t = pgpGrab(v->time, sizeof(v->time));
549 fprintf(stderr, " %-24.24s(0x%08x)", ctime(&t), (unsigned)t);
551 pgpPrtHex(" signer keyid", v->signid, sizeof(v->signid));
552 plen = pgpGrab(v->signhash16, sizeof(v->signhash16));
553 pgpPrtHex(" signhash16", v->signhash16, sizeof(v->signhash16));
556 if (_digp && _digp->pubkey_algo == 0) {
557 _digp->version = v->version;
558 _digp->hashlen = v->hashlen;
559 _digp->sigtype = v->sigtype;
560 _digp->hash = memcpy(xmalloc(v->hashlen), &v->sigtype, v->hashlen);
561 memcpy(_digp->time, v->time, sizeof(_digp->time));
562 memcpy(_digp->signid, v->signid, sizeof(_digp->signid));
563 _digp->pubkey_algo = v->pubkey_algo;
564 _digp->hash_algo = v->hash_algo;
565 memcpy(_digp->signhash16, v->signhash16, sizeof(_digp->signhash16));
568 p = ((byte *)v) + sizeof(*v);
569 rc = pgpPrtSigParams(tag, v->pubkey_algo, v->sigtype, p, h, hlen);
572 { pgpPktSigV4 v = (pgpPktSigV4)h;
574 pgpPrtVal("V4 ", pgpTagTbl, tag);
575 pgpPrtVal(" ", pgpPubkeyTbl, v->pubkey_algo);
576 pgpPrtVal(" ", pgpHashTbl, v->hash_algo);
577 pgpPrtVal(" ", pgpSigTypeTbl, v->sigtype);
581 plen = pgpGrab(v->hashlen, sizeof(v->hashlen));
582 p += sizeof(v->hashlen);
584 if ((p + plen) > (h + hlen))
587 if (_debug && _print)
588 fprintf(stderr, " hash[%u] -- %s\n", plen, pgpHexStr(p, plen));
589 if (_digp && _digp->pubkey_algo == 0) {
590 _digp->hashlen = sizeof(*v) + plen;
591 _digp->hash = memcpy(xmalloc(_digp->hashlen), v, _digp->hashlen);
593 (void) pgpPrtSubType(p, plen, v->sigtype);
599 if ((p + plen) > (h + hlen))
602 if (_debug && _print)
603 fprintf(stderr, " unhash[%u] -- %s\n", plen, pgpHexStr(p, plen));
604 (void) pgpPrtSubType(p, plen, v->sigtype);
608 pgpPrtHex(" signhash16", p, 2);
611 if (_digp && _digp->pubkey_algo == 0) {
612 _digp->version = v->version;
613 _digp->sigtype = v->sigtype;
614 _digp->pubkey_algo = v->pubkey_algo;
615 _digp->hash_algo = v->hash_algo;
616 memcpy(_digp->signhash16, p, sizeof(_digp->signhash16));
623 rc = pgpPrtSigParams(tag, v->pubkey_algo, v->sigtype, p, h, hlen);
632 /*@-varuse =readonlytrans @*/
633 /*@observer@*/ /*@unchecked@*/
634 static const char * pgpPublicRSA[] = {
640 /*@observer@*/ /*@unchecked@*/
641 static const char * pgpSecretRSA[] = {
649 /*@observer@*/ /*@unchecked@*/
650 static const char * pgpPublicDSA[] = {
658 /*@observer@*/ /*@unchecked@*/
659 static const char * pgpSecretDSA[] = {
664 /*@observer@*/ /*@unchecked@*/
665 static const char * pgpPublicELGAMAL[] = {
672 /*@observer@*/ /*@unchecked@*/
673 static const char * pgpSecretELGAMAL[] = {
677 /*@=varuse =readonlytrans @*/
679 static const byte * pgpPrtPubkeyParams(byte pubkey_algo,
680 /*@returned@*/ const byte *p, const byte *h, unsigned int hlen)
681 /*@globals fileSystem, internalState @*/
682 /*@modifies fileSystem, internalState @*/
686 for (i = 0; p < &h[hlen]; i++, p += pgpMpiLen(p)) {
687 if (pubkey_algo == PGPPUBKEYALGO_RSA) {
692 (void) mpbsethex(&_dig->rsa_pk.n, pgpMpiHex(p));
695 uint32_t* np = _dig->rsa_pk.n.modl;
696 size_t nsize = _dig->rsa_pk.n.size;
699 keyid[0] = np[nsize-2];
700 keyid[1] = np[nsize-1];
702 keyid[0] = swapu32(np[nsize-2]);
703 keyid[1] = swapu32(np[nsize-1]);
705 memcpy(_digp->signid, keyid, sizeof(_digp->signid));
707 if (_debug && _print)
708 fprintf(stderr, "\t n = "), mpfprintln(stderr, _dig->rsa_pk.n.size, _dig->rsa_pk.n.modl);
709 /*@switchbreak@*/ break;
711 (void) mpnsethex(&_dig->rsa_pk.e, pgpMpiHex(p));
712 if (_debug && _print)
713 fprintf(stderr, "\t e = "), mpfprintln(stderr, _dig->rsa_pk.e.size, _dig->rsa_pk.e.data);
714 /*@switchbreak@*/ break;
716 /*@switchbreak@*/ break;
719 pgpPrtStr("", pgpPublicRSA[i]);
720 } else if (pubkey_algo == PGPPUBKEYALGO_DSA) {
725 (void) mpbsethex(&_dig->p, pgpMpiHex(p));
726 if (_debug && _print)
727 fprintf(stderr, "\t p = "), mpfprintln(stderr, _dig->p.size, _dig->p.modl);
728 /*@switchbreak@*/ break;
730 (void) mpbsethex(&_dig->q, pgpMpiHex(p));
731 if (_debug && _print)
732 fprintf(stderr, "\t q = "), mpfprintln(stderr, _dig->q.size, _dig->q.modl);
733 /*@switchbreak@*/ break;
735 (void) mpnsethex(&_dig->g, pgpMpiHex(p));
736 if (_debug && _print)
737 fprintf(stderr, "\t g = "), mpfprintln(stderr, _dig->g.size, _dig->g.data);
738 /*@switchbreak@*/ break;
740 (void) mpnsethex(&_dig->y, pgpMpiHex(p));
741 if (_debug && _print)
742 fprintf(stderr, "\t y = "), mpfprintln(stderr, _dig->y.size, _dig->y.data);
743 /*@switchbreak@*/ break;
745 /*@switchbreak@*/ break;
748 pgpPrtStr("", pgpPublicDSA[i]);
749 } else if (pubkey_algo == PGPPUBKEYALGO_ELGAMAL_ENCRYPT) {
751 pgpPrtStr("", pgpPublicELGAMAL[i]);
754 fprintf(stderr, "%7d", i);
756 pgpPrtStr("", pgpMpiStr(p));
763 static const byte * pgpPrtSeckeyParams(/*@unused@*/ byte pubkey_algo,
764 /*@returned@*/ const byte *p, const byte *h, unsigned int hlen)
765 /*@globals fileSystem @*/
766 /*@modifies fileSystem @*/
772 pgpPrtVal(" ", pgpSymkeyTbl, *p);
776 pgpPrtVal(" ", pgpSymkeyTbl, *p);
779 pgpPrtVal(" simple ", pgpHashTbl, p[2]);
781 /*@innerbreak@*/ break;
783 pgpPrtVal(" salted ", pgpHashTbl, p[2]);
784 pgpPrtHex("", p+3, 8);
786 /*@innerbreak@*/ break;
788 pgpPrtVal(" iterated/salted ", pgpHashTbl, p[2]);
789 /*@-shiftnegative -shiftimplementation @*/ /* FIX: unsigned cast */
790 i = (16 + (p[11] & 0xf)) << ((p[11] >> 4) + 6);
791 /*@=shiftnegative =shiftimplementation @*/
792 pgpPrtHex("", p+3, 8);
793 pgpPrtInt(" iter", i);
795 /*@innerbreak@*/ break;
799 pgpPrtVal(" ", pgpSymkeyTbl, *p);
800 pgpPrtHex(" IV", p+1, 8);
808 #ifdef NOTYET /* XXX encrypted MPI's need to be handled. */
809 for (i = 0; p < &h[hlen]; i++, p += pgpMpiLen(p)) {
810 if (pubkey_algo == PGPPUBKEYALGO_RSA) {
811 if (pgpSecretRSA[i] == NULL) break;
812 pgpPrtStr("", pgpSecretRSA[i]);
813 } else if (pubkey_algo == PGPPUBKEYALGO_DSA) {
814 if (pgpSecretDSA[i] == NULL) break;
815 pgpPrtStr("", pgpSecretDSA[i]);
816 } else if (pubkey_algo == PGPPUBKEYALGO_ELGAMAL_ENCRYPT) {
817 if (pgpSecretELGAMAL[i] == NULL) break;
818 pgpPrtStr("", pgpSecretELGAMAL[i]);
821 fprintf(stderr, "%7d", i);
823 pgpPrtStr("", pgpMpiStr(p));
827 pgpPrtHex(" secret", p, (hlen - (p - h) - 2));
829 p += (hlen - (p - h) - 2);
831 pgpPrtHex(" checksum", p, 2);
837 int pgpPrtKey(pgpTag tag, const byte *h, unsigned int hlen)
839 /*@modifies *_digp @*/
849 { pgpPktKeyV3 v = (pgpPktKeyV3)h;
850 pgpPrtVal("V3 ", pgpTagTbl, tag);
851 pgpPrtVal(" ", pgpPubkeyTbl, v->pubkey_algo);
852 t = pgpGrab(v->time, sizeof(v->time));
854 fprintf(stderr, " %-24.24s(0x%08x)", ctime(&t), (unsigned)t);
855 plen = pgpGrab(v->valid, sizeof(v->valid));
857 fprintf(stderr, " valid %u days", plen);
860 if (_digp && _digp->tag == tag) {
861 _digp->version = v->version;
862 memcpy(_digp->time, v->time, sizeof(_digp->time));
863 _digp->pubkey_algo = v->pubkey_algo;
866 p = ((byte *)v) + sizeof(*v);
867 p = pgpPrtPubkeyParams(v->pubkey_algo, p, h, hlen);
871 { pgpPktKeyV4 v = (pgpPktKeyV4)h;
872 pgpPrtVal("V4 ", pgpTagTbl, tag);
873 pgpPrtVal(" ", pgpPubkeyTbl, v->pubkey_algo);
874 t = pgpGrab(v->time, sizeof(v->time));
876 fprintf(stderr, " %-24.24s(0x%08x)", ctime(&t), (unsigned)t);
879 if (_digp && _digp->tag == tag) {
880 _digp->version = v->version;
881 memcpy(_digp->time, v->time, sizeof(_digp->time));
882 _digp->pubkey_algo = v->pubkey_algo;
885 p = ((byte *)v) + sizeof(*v);
886 p = pgpPrtPubkeyParams(v->pubkey_algo, p, h, hlen);
887 if (!(tag == PGPTAG_PUBLIC_KEY || tag == PGPTAG_PUBLIC_SUBKEY))
888 p = pgpPrtSeckeyParams(v->pubkey_algo, p, h, hlen);
899 int pgpPrtUserID(pgpTag tag, const byte *h, unsigned int hlen)
901 /*@modifies *_digp @*/
903 pgpPrtVal("", pgpTagTbl, tag);
905 fprintf(stderr, " \"%.*s\"", (int)hlen, (const char *)h);
909 _digp->userid = t = memcpy(xmalloc(hlen+1), h, hlen);
916 int pgpPrtComment(pgpTag tag, const byte *h, unsigned int hlen)
920 pgpPrtVal("", pgpTagTbl, tag);
922 fprintf(stderr, " ");
925 if (*h >= ' ' && *h <= 'z') {
927 fprintf(stderr, "%s", (const char *)h);
942 int pgpPrtPkt(const byte *pkt, unsigned int pleft)
944 unsigned int val = *pkt;
949 unsigned int hlen = 0;
952 /* XXX can't deal with these. */
958 plen = pgpLen(pkt+1, &hlen);
960 tag = (val >> 2) & 0xf;
961 plen = (1 << (val & 0x3));
962 hlen = pgpGrab(pkt+1, plen);
965 pktlen = 1 + plen + hlen;
971 case PGPTAG_SIGNATURE:
972 rc = pgpPrtSig(tag, h, hlen);
974 case PGPTAG_PUBLIC_KEY:
975 case PGPTAG_PUBLIC_SUBKEY:
976 rc = pgpPrtKey(tag, h, hlen);
978 case PGPTAG_SECRET_KEY:
979 case PGPTAG_SECRET_SUBKEY:
980 rc = pgpPrtKey(tag, h, hlen);
983 rc = pgpPrtUserID(tag, h, hlen);
986 case PGPTAG_COMMENT_OLD:
987 rc = pgpPrtComment(tag, h, hlen);
990 case PGPTAG_RESERVED:
991 case PGPTAG_PUBLIC_SESSION_KEY:
992 case PGPTAG_SYMMETRIC_SESSION_KEY:
993 case PGPTAG_COMPRESSED_DATA:
994 case PGPTAG_SYMMETRIC_DATA:
996 case PGPTAG_LITERAL_DATA:
999 case PGPTAG_ENCRYPTED_MDC:
1001 case PGPTAG_PRIVATE_60:
1002 case PGPTAG_PRIVATE_62:
1003 case PGPTAG_CONTROL:
1005 pgpPrtVal("", pgpTagTbl, tag);
1006 pgpPrtHex("", h, hlen);
1011 return (rc ? -1 : pktlen);
1014 pgpDig pgpNewDig(void)
1016 pgpDig dig = xcalloc(1, sizeof(*dig));
1021 void pgpCleanDig(pgpDig dig)
1025 dig->signature.userid = _free(dig->signature.userid);
1026 dig->pubkey.userid = _free(dig->pubkey.userid);
1027 dig->signature.hash = _free(dig->signature.hash);
1028 dig->pubkey.hash = _free(dig->pubkey.hash);
1029 /*@-unqualifiedtrans@*/ /* FIX: double indirection */
1030 for (i = 0; i < 4; i++) {
1031 dig->signature.params[i] = _free(dig->signature.params[i]);
1032 dig->pubkey.params[i] = _free(dig->pubkey.params[i]);
1034 /*@=unqualifiedtrans@*/
1036 memset(&dig->signature, 0, sizeof(dig->signature));
1037 memset(&dig->pubkey, 0, sizeof(dig->pubkey));
1039 dig->md5 = _free(dig->md5);
1040 dig->sha1 = _free(dig->sha1);
1045 (void) rsapkFree(&dig->rsa_pk);
1048 mpnfree(&dig->rsahm);
1056 pgpDig pgpFreeDig(/*@only@*/ /*@null@*/ pgpDig dig)
1061 /* DUmp the signature/pubkey data. */
1065 if (dig->hdrsha1ctx != NULL)
1066 (void) rpmDigestFinal(dig->hdrsha1ctx, NULL, NULL, 0);
1068 dig->hdrsha1ctx = NULL;
1071 if (dig->sha1ctx != NULL)
1072 (void) rpmDigestFinal(dig->sha1ctx, NULL, NULL, 0);
1074 dig->sha1ctx = NULL;
1086 if (dig->hdrmd5ctx != NULL)
1087 (void) rpmDigestFinal(dig->hdrmd5ctx, NULL, NULL, 0);
1089 dig->hdrmd5ctx = NULL;
1093 if (dig->md5ctx != NULL)
1094 (void) rpmDigestFinal(dig->md5ctx, NULL, NULL, 0);
1098 mpbfree(&dig->rsa_pk.n);
1099 mpnfree(&dig->rsa_pk.e);
1109 int pgpPrtPkts(const byte * pkts, unsigned int pktlen, pgpDig dig, int printing)
1110 /*@globals _dig, _digp, _print @*/
1111 /*@modifies _dig, _digp, *_digp, _print @*/
1113 unsigned int val = *pkts;
1120 if (dig != NULL && (val & 0x80)) {
1121 pgpTag tag = (val & 0x40) ? (val & 0x3f) : ((val >> 2) & 0xf);
1122 _digp = (tag == PGPTAG_SIGNATURE) ? &_dig->signature : &_dig->pubkey;
1127 for (p = pkts, pleft = pktlen; p < (pkts + pktlen); p += len, pleft -= len) {
1128 len = pgpPrtPkt(p, pleft);
1131 if (len > pleft) /* XXX shouldn't happen */
1138 pgpArmor pgpReadPkts(const char * fn, const byte ** pkt, size_t * pktlen)
1140 const byte * b = NULL;
1142 const char * enc = NULL;
1143 const char * crcenc = NULL;
1148 uint32_t crcpkt, crc;
1149 const char * armortype = NULL;
1152 pgpArmor ec = PGPARMOR_ERROR; /* XXX assume failure */
1155 rc = rpmioSlurp(fn, &b, &blen);
1156 if (rc || b == NULL || blen <= 0) {
1161 #ifdef NOTYET /* XXX ASCII Pubkeys only, please. */
1162 ec = 0; /* XXX fish out pkt type. */
1167 #define TOKEQ(_s, _tok) (!strncmp((_s), (_tok), sizeof(_tok)-1))
1169 for (t = (char *)b; t && *t; t = te) {
1170 if ((te = strchr(t, '\n')) == NULL)
1178 if (!TOKEQ(t, "-----BEGIN PGP "))
1180 t += sizeof("-----BEGIN PGP ")-1;
1182 rc = pgpValTok(pgpArmorTbl, t, te);
1185 if (rc != PGPARMOR_PUBKEY) /* XXX ASCII Pubkeys only, please. */
1189 t = te - (sizeof("-----\n")-1);
1190 if (!TOKEQ(t, "-----\n"))
1194 /*@switchbreak@*/ break;
1197 rc = pgpValTok(pgpArmorKeyTbl, t, te);
1204 enc = te; /* Start of encoded packets */
1206 /*@switchbreak@*/ break;
1211 *t++ = '\0'; /* Terminate encoded packets */
1212 crcenc = t; /* Start of encoded crc */
1214 /*@switchbreak@*/ break;
1217 if (!TOKEQ(t, "-----END PGP "))
1219 *t = '\0'; /* Terminate encoded crc */
1220 t += sizeof("-----END PGP ")-1;
1222 if (armortype == NULL) /* XXX can't happen */
1224 rc = strncmp(t, armortype, strlen(armortype));
1228 t = te - (sizeof("-----\n")-1);
1229 if (!TOKEQ(t, "-----\n"))
1234 if (b64decode(crcenc, (void **)&crcdec, &crclen) != 0)
1236 crcpkt = pgpGrab(crcdec, crclen);
1237 crcdec = _free(crcdec);
1240 if (b64decode(enc, (void **)&dec, &declen) != 0)
1242 crc = pgpCRC(dec, declen);
1248 ec = PGPARMOR_PUBKEY; /* XXX ASCII Pubkeys only, please. */
1250 /*@notreached@*/ /*@switchbreak@*/ break;
1256 if (ec > PGPARMOR_NONE && pkt)
1266 char * pgpArmorWrap(int atype, const unsigned char * s, size_t ns)
1274 nt = ((ns + 2) / 3) * 4;
1276 /* Add additional bytes necessary for eol string(s). */
1277 if (b64encode_chars_per_line > 0 && b64encode_eolstr != NULL) {
1278 lc = (nt + b64encode_chars_per_line - 1) / b64encode_chars_per_line;
1279 if (((nt + b64encode_chars_per_line - 1) % b64encode_chars_per_line) != 0)
1281 nt += lc * strlen(b64encode_eolstr);
1285 nt += 512; /* XXX slop for armor and crc */
1288 val = t = xmalloc(nt + 1);
1290 t = stpcpy(t, "-----BEGIN PGP ");
1291 t = stpcpy(t, pgpValStr(pgpArmorTbl, atype));
1293 t = stpcpy( stpcpy(t, "-----\nVersion: rpm-"), VERSION);
1295 t = stpcpy(t, " (beecrypt-3.0.0)\n\n");
1297 if ((enc = b64encode(s, ns)) != NULL) {
1300 if ((enc = b64crc(s, ns)) != NULL) {
1307 t = stpcpy(t, "-----END PGP ");
1308 t = stpcpy(t, pgpValStr(pgpArmorTbl, atype));
1309 t = stpcpy(t, "-----\n");
1312 /*@-globstate@*/ /* XXX b64encode_eolstr */