rpm
4.5
Main Page
Related Pages
Modules
Data Structures
Files
File List
Globals
rpmio
rpmpgp.h
Go to the documentation of this file.
1
#ifndef H_RPMPGP
2
#define H_RPMPGP
3
13
#include <popt.h>
14
15
#if !defined(_BEECRYPT_API_H)
16
/*@-redef@*/
17
typedef
unsigned
char
byte
;
18
/*@=redef@*/
19
#endif
/* _BEECRYPT_API_H */
20
23
typedef
/*@abstract@*/
struct
DIGEST_CTX_s
*
DIGEST_CTX
;
24
27
typedef
/*@abstract@*/
struct
pgpPkt_s
*
pgpPkt
;
28
31
typedef
const
struct
pgpValTbl_s
{
32
int
val
;
33
/*@observer@*/
const
char
*
str
;
34
} *
pgpValTbl
;
35
43
typedef
enum
pgpTag_e
{
44
PGPTAG_RESERVED
= 0,
45
PGPTAG_PUBLIC_SESSION_KEY
= 1,
46
PGPTAG_SIGNATURE
= 2,
47
PGPTAG_SYMMETRIC_SESSION_KEY
= 3,
48
PGPTAG_ONEPASS_SIGNATURE
= 4,
49
PGPTAG_SECRET_KEY
= 5,
50
PGPTAG_PUBLIC_KEY
= 6,
51
PGPTAG_SECRET_SUBKEY
= 7,
52
PGPTAG_COMPRESSED_DATA
= 8,
53
PGPTAG_SYMMETRIC_DATA
= 9,
54
PGPTAG_MARKER
= 10,
55
PGPTAG_LITERAL_DATA
= 11,
56
PGPTAG_TRUST
= 12,
57
PGPTAG_USER_ID
= 13,
58
PGPTAG_PUBLIC_SUBKEY
= 14,
59
PGPTAG_COMMENT_OLD
= 16,
60
PGPTAG_PHOTOID
= 17,
61
PGPTAG_ENCRYPTED_MDC
= 18,
62
PGPTAG_MDC
= 19,
63
PGPTAG_PRIVATE_60
= 60,
64
PGPTAG_COMMENT
= 61,
65
PGPTAG_PRIVATE_62
= 62,
66
PGPTAG_CONTROL
= 63
67
}
pgpTag
;
68
71
/*@observer@*/
/*@unchecked@*/
/*@unused@*/
72
extern
struct
pgpValTbl_s
pgpTagTbl
[];
73
108
typedef
struct
pgpPktPubkey_s
{
109
byte
version
;
110
byte
keyid
[8];
111
byte
algo
;
112
}
pgpPktPubkey
;
113
114
121
/*@-typeuse@*/
122
typedef
enum
pgpSigType_e
{
123
PGPSIGTYPE_BINARY
= 0x00,
124
PGPSIGTYPE_TEXT
= 0x01,
125
PGPSIGTYPE_STANDALONE
= 0x02,
126
PGPSIGTYPE_GENERIC_CERT
= 0x10,
128
PGPSIGTYPE_PERSONA_CERT
= 0x11,
130
PGPSIGTYPE_CASUAL_CERT
= 0x12,
132
PGPSIGTYPE_POSITIVE_CERT
= 0x13,
134
PGPSIGTYPE_SUBKEY_BINDING
= 0x18,
135
PGPSIGTYPE_SIGNED_KEY
= 0x1F,
136
PGPSIGTYPE_KEY_REVOKE
= 0x20,
137
PGPSIGTYPE_SUBKEY_REVOKE
= 0x28,
138
PGPSIGTYPE_CERT_REVOKE
= 0x30,
139
PGPSIGTYPE_TIMESTAMP
= 0x40
140
}
pgpSigType
;
141
/*@=typeuse@*/
142
145
/*@observer@*/
/*@unchecked@*/
/*@unused@*/
146
extern
struct
pgpValTbl_s
pgpSigTypeTbl
[];
147
171
/*@-typeuse@*/
172
typedef
enum
pgpPubkeyAlgo_e
{
173
PGPPUBKEYALGO_RSA
= 1,
174
PGPPUBKEYALGO_RSA_ENCRYPT
= 2,
175
PGPPUBKEYALGO_RSA_SIGN
= 3,
176
PGPPUBKEYALGO_ELGAMAL_ENCRYPT
= 16,
177
PGPPUBKEYALGO_DSA
= 17,
178
PGPPUBKEYALGO_EC
= 18,
179
PGPPUBKEYALGO_ECDSA
= 19,
180
PGPPUBKEYALGO_ELGAMAL
= 20,
181
PGPPUBKEYALGO_DH
= 21
182
}
pgpPubkeyAlgo
;
183
/*@=typeuse@*/
184
187
/*@observer@*/
/*@unchecked@*/
/*@unused@*/
188
extern
struct
pgpValTbl_s
pgpPubkeyTbl
[];
189
214
/*@-typeuse@*/
215
typedef
enum
pgpSymkeyAlgo_e
{
216
PGPSYMKEYALGO_PLAINTEXT
= 0,
217
PGPSYMKEYALGO_IDEA
= 1,
218
PGPSYMKEYALGO_TRIPLE_DES
= 2,
219
PGPSYMKEYALGO_CAST5
= 3,
220
PGPSYMKEYALGO_BLOWFISH
= 4,
221
PGPSYMKEYALGO_SAFER
= 5,
222
PGPSYMKEYALGO_DES_SK
= 6,
223
PGPSYMKEYALGO_AES_128
= 7,
224
PGPSYMKEYALGO_AES_192
= 8,
225
PGPSYMKEYALGO_AES_256
= 9,
226
PGPSYMKEYALGO_TWOFISH
= 10,
227
PGPSYMKEYALGO_NOENCRYPT
= 110
228
}
pgpSymkeyAlgo
;
229
/*@=typeuse@*/
230
234
/*@observer@*/
/*@unchecked@*/
/*@unused@*/
235
extern
struct
pgpValTbl_s
pgpSymkeyTbl
[];
236
252
/*@-typeuse@*/
253
typedef
enum
pgpCompressAlgo_e
{
254
PGPCOMPRESSALGO_NONE
= 0,
255
PGPCOMPRESSALGO_ZIP
= 1,
256
PGPCOMPRESSALGO_ZLIB
= 2,
257
PGPCOMPRESSALGO_BZIP2
= 3
258
}
pgpCompressAlgo
;
259
/*@=typeuse@*/
260
264
/*@observer@*/
/*@unchecked@*/
/*@unused@*/
265
extern
struct
pgpValTbl_s
pgpCompressionTbl
[];
266
288
typedef
enum
pgpHashAlgo_e
{
289
PGPHASHALGO_ERROR
= -1,
290
PGPHASHALGO_NONE
= 0,
291
PGPHASHALGO_MD5
= 1,
292
PGPHASHALGO_SHA1
= 2,
293
PGPHASHALGO_RIPEMD160
= 3,
294
PGPHASHALGO_MD2
= 5,
295
PGPHASHALGO_TIGER192
= 6,
296
PGPHASHALGO_HAVAL_5_160
= 7,
297
PGPHASHALGO_SHA256
= 8,
298
PGPHASHALGO_SHA384
= 9,
299
PGPHASHALGO_SHA512
= 10,
301
PGPHASHALGO_MD4
= 104,
302
PGPHASHALGO_RIPEMD128
= 105,
303
PGPHASHALGO_CRC32
= 106,
304
PGPHASHALGO_ADLER32
= 107,
305
PGPHASHALGO_CRC64
= 108,
306
PGPHASHALGO_JLU32
= 109,
307
PGPHASHALGO_SHA224
= 110,
308
PGPHASHALGO_RIPEMD256
= 111,
309
PGPHASHALGO_RIPEMD320
= 112,
310
PGPHASHALGO_SALSA10
= 113,
311
PGPHASHALGO_SALSA20
= 114,
313
}
pgpHashAlgo
;
314
318
/*@observer@*/
/*@unchecked@*/
/*@unused@*/
319
extern
struct
pgpValTbl_s
pgpHashTbl
[];
320
342
typedef
struct
pgpPktSigV3_s
{
343
byte
version
;
344
byte
hashlen
;
345
byte
sigtype
;
346
byte
time
[4];
347
byte
signid
[8];
348
byte
pubkey_algo
;
349
byte
hash_algo
;
350
byte
signhash16
[2];
351
} *
pgpPktSigV3
;
352
374
typedef
struct
pgpPktSigV4_s
{
375
byte
version
;
376
byte
sigtype
;
377
byte
pubkey_algo
;
378
byte
hash_algo
;
379
byte
hashlen
[2];
380
} *
pgpPktSigV4
;
381
448
/*@-typeuse@*/
449
typedef
enum
pgpSubType_e
{
450
PGPSUBTYPE_NONE
= 0,
451
PGPSUBTYPE_SIG_CREATE_TIME
= 2,
452
PGPSUBTYPE_SIG_EXPIRE_TIME
= 3,
453
PGPSUBTYPE_EXPORTABLE_CERT
= 4,
454
PGPSUBTYPE_TRUST_SIG
= 5,
455
PGPSUBTYPE_REGEX
= 6,
456
PGPSUBTYPE_REVOCABLE
= 7,
457
PGPSUBTYPE_KEY_EXPIRE_TIME
= 9,
458
PGPSUBTYPE_ARR
= 10,
459
PGPSUBTYPE_PREFER_SYMKEY
= 11,
460
PGPSUBTYPE_REVOKE_KEY
= 12,
461
PGPSUBTYPE_ISSUER_KEYID
= 16,
462
PGPSUBTYPE_NOTATION
= 20,
463
PGPSUBTYPE_PREFER_HASH
= 21,
464
PGPSUBTYPE_PREFER_COMPRESS
= 22,
465
PGPSUBTYPE_KEYSERVER_PREFERS
= 23,
466
PGPSUBTYPE_PREFER_KEYSERVER
= 24,
467
PGPSUBTYPE_PRIMARY_USERID
= 25,
468
PGPSUBTYPE_POLICY_URL
= 26,
469
PGPSUBTYPE_KEY_FLAGS
= 27,
470
PGPSUBTYPE_SIGNER_USERID
= 28,
471
PGPSUBTYPE_REVOKE_REASON
= 29,
472
PGPSUBTYPE_FEATURES
= 30,
473
PGPSUBTYPE_EMBEDDED_SIG
= 32,
475
PGPSUBTYPE_INTERNAL_100
= 100,
476
PGPSUBTYPE_INTERNAL_101
= 101,
477
PGPSUBTYPE_INTERNAL_102
= 102,
478
PGPSUBTYPE_INTERNAL_103
= 103,
479
PGPSUBTYPE_INTERNAL_104
= 104,
480
PGPSUBTYPE_INTERNAL_105
= 105,
481
PGPSUBTYPE_INTERNAL_106
= 106,
482
PGPSUBTYPE_INTERNAL_107
= 107,
483
PGPSUBTYPE_INTERNAL_108
= 108,
484
PGPSUBTYPE_INTERNAL_109
= 109,
485
PGPSUBTYPE_INTERNAL_110
= 110,
487
PGPSUBTYPE_CRITICAL
= 128
488
}
pgpSubType
;
489
/*@=typeuse@*/
490
494
/*@observer@*/
/*@unchecked@*/
/*@unused@*/
495
extern
struct
pgpValTbl_s
pgpSubTypeTbl
[];
496
517
typedef
union
pgpPktSig_u
{
518
struct
pgpPktSigV3_s
v3
;
519
struct
pgpPktSigV4_s
v4
;
520
} *
pgpPktSig
;
521
550
typedef
struct
pgpPktSymkey_s
{
551
byte
version
;
552
byte
symkey_algo
;
553
byte
s2k
[1];
554
}
pgpPktSymkey
;
555
585
typedef
struct
pgpPktOnepass_s
{
586
byte
version
;
587
byte
sigtype
;
588
byte
hash_algo
;
589
byte
pubkey_algo
;
590
byte
signid
[8];
591
byte
nested
;
592
} *
pgpPktOnepass
;
593
666
typedef
struct
pgpPktKeyV3_s
{
667
byte
version
;
668
byte
time
[4];
669
byte
valid
[2];
670
byte
pubkey_algo
;
671
} *
pgpPktKeyV3
;
672
704
typedef
struct
pgpPktKeyV4_s
{
705
byte
version
;
706
byte
time
[4];
707
byte
pubkey_algo
;
708
} *
pgpPktKeyV4
;
709
774
typedef
union
pgpPktKey_u
{
775
struct
pgpPktKeyV3_s
v3
;
776
struct
pgpPktKeyV4_s
v4
;
777
}
pgpPktKey
;
778
779
/*
780
* 5.6. Compressed Data Packet (Tag 8)
781
*
782
* The Compressed Data packet contains compressed data. Typically, this
783
* packet is found as the contents of an encrypted packet, or following
784
* a Signature or One-Pass Signature packet, and contains literal data
785
* packets.
786
*
787
* The body of this packet consists of:
788
* - One octet that gives the algorithm used to compress the packet.
789
* - The remainder of the packet is compressed data.
790
*
791
* A Compressed Data Packet's body contains an block that compresses
792
* some set of packets. See section "Packet Composition" for details on
793
* how messages are formed.
794
*
795
* ZIP-compressed packets are compressed with raw RFC 1951 DEFLATE
796
* blocks. Note that PGP V2.6 uses 13 bits of compression. If an
797
* implementation uses more bits of compression, PGP V2.6 cannot
798
* decompress it.
799
*
800
* ZLIB-compressed packets are compressed with RFC 1950 ZLIB-style
801
* blocks.
802
*/
803
typedef
struct
pgpPktCdata_s
{
804
byte
compressalgo
;
805
byte
data
[1];
806
}
pgpPktCdata
;
807
808
/*
809
* 5.7. Symmetrically Encrypted Data Packet (Tag 9)
810
*
811
* The Symmetrically Encrypted Data packet contains data encrypted with
812
* a symmetric-key algorithm. When it has been decrypted, it will
813
* typically contain other packets (often literal data packets or
814
* compressed data packets).
815
*
816
* The body of this packet consists of:
817
* - Encrypted data, the output of the selected symmetric-key cipher
818
* operating in PGP's variant of Cipher Feedback (CFB) mode.
819
*
820
* The symmetric cipher used may be specified in an Public-Key or
821
* Symmetric-Key Encrypted Session Key packet that precedes the
822
* Symmetrically Encrypted Data Packet. In that case, the cipher
823
* algorithm octet is prefixed to the session key before it is
824
* encrypted. If no packets of these types precede the encrypted data,
825
* the IDEA algorithm is used with the session key calculated as the MD5
826
* hash of the passphrase.
827
*
828
* The data is encrypted in CFB mode, with a CFB shift size equal to the
829
* cipher's block size. The Initial Vector (IV) is specified as all
830
* zeros. Instead of using an IV, OpenPGP prefixes a 10-octet string to
831
* the data before it is encrypted. The first eight octets are random,
832
* and the 9th and 10th octets are copies of the 7th and 8th octets,
833
* respectively. After encrypting the first 10 octets, the CFB state is
834
* resynchronized if the cipher block size is 8 octets or less. The
835
* last 8 octets of ciphertext are passed through the cipher and the
836
* block boundary is reset.
837
*
838
* The repetition of 16 bits in the 80 bits of random data prefixed to
839
* the message allows the receiver to immediately check whether the
840
* session key is incorrect.
841
*/
842
typedef
struct
pgpPktEdata_s
{
843
byte
data
[1];
844
}
pgpPktEdata
;
845
846
/*
847
* 5.8. Marker Packet (Obsolete Literal Packet) (Tag 10)
848
*
849
* An experimental version of PGP used this packet as the Literal
850
* packet, but no released version of PGP generated Literal packets with
851
* this tag. With PGP 5.x, this packet has been re-assigned and is
852
* reserved for use as the Marker packet.
853
*
854
* The body of this packet consists of:
855
* - The three octets 0x50, 0x47, 0x50 (which spell "PGP" in UTF-8).
856
*
857
* Such a packet MUST be ignored when received. It may be placed at the
858
* beginning of a message that uses features not available in PGP 2.6.x
859
* in order to cause that version to report that newer software is
860
* necessary to process the message.
861
*/
862
/*
863
* 5.9. Literal Data Packet (Tag 11)
864
*
865
* A Literal Data packet contains the body of a message; data that is
866
* not to be further interpreted.
867
*
868
* The body of this packet consists of:
869
* - A one-octet field that describes how the data is formatted.
870
*
871
* If it is a 'b' (0x62), then the literal packet contains binary data.
872
* If it is a 't' (0x74), then it contains text data, and thus may need
873
* line ends converted to local form, or other text-mode changes. RFC
874
* 1991 also defined a value of 'l' as a 'local' mode for machine-local
875
* conversions. This use is now deprecated.
876
* - File name as a string (one-octet length, followed by file name),
877
* if the encrypted data should be saved as a file.
878
*
879
* If the special name "_CONSOLE" is used, the message is considered to
880
* be "for your eyes only". This advises that the message data is
881
* unusually sensitive, and the receiving program should process it more
882
* carefully, perhaps avoiding storing the received data to disk, for
883
* example.
884
* - A four-octet number that indicates the modification date of the
885
* file, or the creation time of the packet, or a zero that
886
* indicates the present time.
887
* - The remainder of the packet is literal data.
888
*
889
* Text data is stored with <CR><LF> text endings (i.e. network-normal
890
* line endings). These should be converted to native line endings by
891
* the receiving software.
892
*/
893
typedef
struct
pgpPktLdata_s
{
894
byte
format
;
895
byte
filenamelen
;
896
byte
filename
[1];
897
}
pgpPktLdata
;
898
899
/*
900
* 5.10. Trust Packet (Tag 12)
901
*
902
* The Trust packet is used only within keyrings and is not normally
903
* exported. Trust packets contain data that record the user's
904
* specifications of which key holders are trustworthy introducers,
905
* along with other information that implementing software uses for
906
* trust information.
907
*
908
* Trust packets SHOULD NOT be emitted to output streams that are
909
* transferred to other users, and they SHOULD be ignored on any input
910
* other than local keyring files.
911
*/
912
typedef
struct
pgpPktTrust_s
{
913
byte
flag
;
914
}
pgpPktTrust
;
915
916
/*
917
* 5.11. User ID Packet (Tag 13)
918
*
919
* A User ID packet consists of data that is intended to represent the
920
* name and email address of the key holder. By convention, it includes
921
* an RFC 822 mail name, but there are no restrictions on its content.
922
* The packet length in the header specifies the length of the user id.
923
* If it is text, it is encoded in UTF-8.
924
*
925
*/
926
typedef
struct
pgpPktUid_s
{
927
byte
userid
[1];
928
}
pgpPktUid
;
929
932
union
pgpPktPre_u
{
933
pgpPktPubkey
pubkey
;
934
pgpPktSig
sig
;
935
pgpPktSymkey
symkey
;
936
pgpPktOnepass
onepass
;
937
pgpPktKey
key
;
938
pgpPktCdata
cdata
;
939
pgpPktEdata
edata
;
941
pgpPktLdata
ldata
;
942
pgpPktTrust
tdata
;
943
pgpPktUid
uid
;
944
};
945
948
/*@-typeuse@*/
949
typedef
enum
pgpArmor_e
{
950
PGPARMOR_ERR_CRC_CHECK
= -7,
951
PGPARMOR_ERR_BODY_DECODE
= -6,
952
PGPARMOR_ERR_CRC_DECODE
= -5,
953
PGPARMOR_ERR_NO_END_PGP
= -4,
954
PGPARMOR_ERR_UNKNOWN_PREAMBLE_TAG
= -3,
955
PGPARMOR_ERR_UNKNOWN_ARMOR_TYPE
= -2,
956
PGPARMOR_ERR_NO_BEGIN_PGP
= -1,
957
#define PGPARMOR_ERROR PGPARMOR_ERR_NO_BEGIN_PGP
958
PGPARMOR_NONE
= 0,
959
PGPARMOR_MESSAGE
= 1,
960
PGPARMOR_PUBKEY
= 2,
961
PGPARMOR_SIGNATURE
= 3,
962
PGPARMOR_SIGNED_MESSAGE
= 4,
963
PGPARMOR_FILE
= 5,
964
PGPARMOR_PRIVKEY
= 6,
965
PGPARMOR_SECKEY
= 7
966
}
pgpArmor
;
967
/*@=typeuse@*/
968
972
/*@observer@*/
/*@unchecked@*/
/*@unused@*/
973
extern
struct
pgpValTbl_s
pgpArmorTbl
[];
974
977
/*@-typeuse@*/
978
typedef
enum
pgpArmorKey_e
{
979
PGPARMORKEY_VERSION
= 1,
980
PGPARMORKEY_COMMENT
= 2,
981
PGPARMORKEY_MESSAGEID
= 3,
982
PGPARMORKEY_HASH
= 4,
983
PGPARMORKEY_CHARSET
= 5
984
}
pgpArmorKey
;
985
/*@=typeuse@*/
986
990
/*@observer@*/
/*@unchecked@*/
/*@unused@*/
991
extern
struct
pgpValTbl_s
pgpArmorKeyTbl
[];
992
996
typedef
enum
rpmDigestFlags_e
{
997
RPMDIGEST_NONE
= 0
998
}
rpmDigestFlags
;
999
1000
/*@unchecked@*/
1001
extern
pgpHashAlgo
rpmDigestHashAlgo
;
1002
1003
/*@unchecked@*/
/*@observer@*/
1004
extern
struct
poptOption
rpmDigestPoptTable
[];
1005
1006
/*@-fcnuse@*/
1007
#ifdef __cplusplus
1008
extern
"C"
{
1009
#endif
1010
1017
/*@unused@*/
static
inline
1018
unsigned
int
pgpGrab
(
const
byte
*s,
int
nbytes)
1019
/*@*/
1020
{
1021
unsigned
int
i = 0;
1022
int
nb = (nbytes <=
sizeof
(i) ? nbytes :
sizeof
(i));
1023
/*@-boundsread@*/
1024
while
(nb--)
1025
i = (i << 8) | *s++;
1026
/*@=boundsread@*/
1027
return
i;
1028
}
1029
1036
/*@unused@*/
static
inline
1037
int
pgpLen
(
const
byte
*s,
/*@out@*/
unsigned
int
*lenp)
1038
/*@modifies *lenp @*/
1039
{
1040
/*@-boundswrite@*/
1041
if
(*s < 192) {
1042
(*lenp) = *s++;
1043
return
1;
1044
}
else
if
(*s < 255) {
1045
(*lenp) = ((((unsigned)s[0]) - 192) << 8) + s[1] + 192;
1046
return
2;
1047
}
else
{
1048
(*lenp) =
pgpGrab
(s+1, 4);
1049
return
5;
1050
}
1051
/*@=boundswrite@*/
1052
}
1053
1059
/*@unused@*/
static
inline
1060
unsigned
int
pgpMpiBits
(
const
byte
*p)
1061
/*@requires maxRead(p) >= 1 @*/
1062
/*@*/
1063
{
1064
return
((p[0] << 8) | p[1]);
1065
}
1066
1072
/*@unused@*/
static
inline
1073
unsigned
int
pgpMpiLen
(
const
byte
*p)
1074
/*@requires maxRead(p) >= 1 @*/
1075
/*@*/
1076
{
1077
return
(2 + ((
pgpMpiBits
(p)+7)>>3));
1078
}
1079
1087
/*@unused@*/
static
inline
1088
char
*
pgpHexCvt
(
/*@returned@*/
char
*t,
const
byte
*s,
int
nbytes)
1089
/*@modifies *t @*/
1090
{
1091
static
char
hex[] =
"0123456789abcdef"
;
1092
/*@-boundswrite@*/
1093
while
(nbytes-- > 0) {
1094
unsigned
int
i;
1095
i = *s++;
1096
*t++ = hex[ (i >> 4) & 0xf ];
1097
*t++ = hex[ (i ) & 0xf ];
1098
}
1099
*t =
'\0'
;
1100
/*@=boundswrite@*/
1101
return
t;
1102
}
1103
1111
/*@unused@*/
static
inline
/*@observer@*/
1112
char
*
pgpHexStr
(
const
byte
*p,
unsigned
int
plen)
1113
/*@*/
1114
{
1115
static
char
prbuf[8*BUFSIZ];
/* XXX ick */
1116
char
*t = prbuf;
1117
t =
pgpHexCvt
(t, p, plen);
1118
return
prbuf;
1119
}
1120
1127
/*@unused@*/
static
inline
/*@observer@*/
1128
const
char
*
pgpMpiStr
(
const
byte
*p)
1129
/*@requires maxRead(p) >= 3 @*/
1130
/*@*/
1131
{
1132
static
char
prbuf[8*BUFSIZ];
/* XXX ick */
1133
char
*t = prbuf;
1134
sprintf(t,
"[%4u]: "
,
pgpGrab
(p, 2));
1135
t += strlen(t);
1136
t =
pgpHexCvt
(t, p+2,
pgpMpiLen
(p)-2);
1137
return
prbuf;
1138
}
1139
1146
/*@unused@*/
static
inline
/*@observer@*/
1147
const
char
*
pgpValStr
(
pgpValTbl
vs,
byte
val)
1148
/*@*/
1149
{
1150
do
{
1151
if
(vs->
val
== val)
1152
break
;
1153
}
while
((++vs)->val != -1);
1154
return
vs->
str
;
1155
}
1156
1164
/*@unused@*/
static
inline
1165
int
pgpValTok
(
pgpValTbl
vs,
const
char
* s,
const
char
* se)
1166
/*@*/
1167
{
1168
do
{
1169
int
vlen = strlen(vs->
str
);
1170
if
(vlen <= (se-s) && !strncmp(s, vs->
str
, vlen))
1171
break
;
1172
}
while
((++vs)->val != -1);
1173
return
vs->
val
;
1174
}
1175
1182
/*@-exportlocal@*/
1183
void
pgpPrtVal
(
const
char
* pre,
pgpValTbl
vs,
byte
val)
1184
/*@globals fileSystem @*/
1185
/*@modifies fileSystem @*/
;
1186
/*@=exportlocal@*/
1187
1195
/*@-exportlocal@*/
1196
int
pgpPrtSubType
(
const
byte
*h,
unsigned
int
hlen,
pgpSigType
sigtype)
1197
/*@globals fileSystem @*/
1198
/*@modifies fileSystem @*/
;
1199
/*@=exportlocal@*/
1200
1206
/*@-exportlocal@*/
1207
int
pgpPrtSig
(
const
pgpPkt pp)
1208
/*@globals fileSystem, internalState @*/
1209
/*@modifies fileSystem, internalState @*/
;
1210
/*@=exportlocal@*/
1211
1217
int
pgpPrtKey
(
const
pgpPkt pp)
1218
/*@globals fileSystem, internalState @*/
1219
/*@modifies fileSystem, internalState @*/
;
1220
1226
/*@-exportlocal@*/
1227
int
pgpPrtUserID
(
const
pgpPkt pp)
1228
/*@globals fileSystem, internalState @*/
1229
/*@modifies fileSystem, internalState @*/
;
1230
/*@=exportlocal@*/
1231
1237
/*@-exportlocal@*/
1238
int
pgpPrtComment
(
const
pgpPkt pp)
1239
/*@globals fileSystem @*/
1240
/*@modifies fileSystem @*/
;
1241
/*@=exportlocal@*/
1242
1251
/*@-exportlocal@*/
1252
int
pgpPubkeyFingerprint
(
const
byte
* pkt,
unsigned
int
pktlen,
1253
/*@out@*/
byte
* keyid)
1254
/*@modifies *keyid @*/
;
1255
/*@=exportlocal@*/
1256
1264
int
pgpExtractPubkeyFingerprint
(
const
char
* b64pkt,
/*@out@*/
byte
* keyid)
1265
/*@modifies *keyid @*/
;
1266
1274
int
pgpPktLen
(
const
byte
*pkt,
unsigned
int
pleft,
/*@out@*/
pgpPkt pp)
1275
/*@modifies pp @*/
;
1276
1283
/*@-exportlocal@*/
1284
int
pgpPrtPkt
(
const
byte
*pkt,
unsigned
int
pleft)
1285
/*@globals fileSystem, internalState @*/
1286
/*@modifies fileSystem, internalState @*/
;
1287
/*@=exportlocal@*/
1288
1297
int
pgpPrtPkts
(
const
byte
*pkts,
unsigned
int
pktlen,
pgpDig
dig,
int
printing)
1298
/*@globals fileSystem, internalState @*/
1299
/*@modifies dig, fileSystem, internalState @*/
;
1300
1308
pgpArmor
pgpReadPkts
(
const
char
* fn,
1309
/*@out@*/
const
byte
** pkt,
/*@out@*/
size_t
* pktlen)
1310
/*@globals h_errno, fileSystem, internalState @*/
1311
/*@modifies *pkt, *pktlen, fileSystem, internalState @*/
;
1312
1320
char
*
pgpArmorWrap
(
int
atype,
const
unsigned
char
* s,
size_t
ns)
1321
/*@*/
;
1322
1327
/*@only@*/
1328
pgpDig
pgpNewDig
(
void
)
1329
/*@*/
;
1330
1335
void
pgpCleanDig
(
/*@null@*/
pgpDig
dig)
1336
/*@modifies dig @*/
;
1337
1343
/*@only@*/
/*@null@*/
1344
pgpDig
pgpFreeDig
(
/*@only@*/
/*@null@*/
pgpDig
dig)
1345
/*@modifies dig @*/
;
1346
1352
/*@unused@*/
static
inline
1353
int
pgpIsPkt
(
const
byte
* p)
1354
/*@*/
1355
{
1356
/*@-boundsread@*/
1357
unsigned
int
val = *p++;
1358
/*@=boundsread@*/
1359
pgpTag
tag;
1360
int
rc;
1361
1362
/* XXX can't deal with these. */
1363
if
(!(val & 0x80))
1364
return
0;
1365
1366
if
(val & 0x40)
1367
tag = (val & 0x3f);
1368
else
1369
tag = (val >> 2) & 0xf;
1370
1371
switch
(tag) {
1372
case
PGPTAG_MARKER
:
1373
case
PGPTAG_SYMMETRIC_SESSION_KEY
:
1374
case
PGPTAG_ONEPASS_SIGNATURE
:
1375
case
PGPTAG_PUBLIC_KEY
:
1376
case
PGPTAG_SECRET_KEY
:
1377
case
PGPTAG_PUBLIC_SESSION_KEY
:
1378
case
PGPTAG_SIGNATURE
:
1379
case
PGPTAG_COMMENT
:
1380
case
PGPTAG_COMMENT_OLD
:
1381
case
PGPTAG_LITERAL_DATA
:
1382
case
PGPTAG_COMPRESSED_DATA
:
1383
case
PGPTAG_SYMMETRIC_DATA
:
1384
rc = 1;
1385
break
;
1386
case
PGPTAG_PUBLIC_SUBKEY
:
1387
case
PGPTAG_SECRET_SUBKEY
:
1388
case
PGPTAG_USER_ID
:
1389
case
PGPTAG_RESERVED
:
1390
case
PGPTAG_TRUST
:
1391
case
PGPTAG_PHOTOID
:
1392
case
PGPTAG_ENCRYPTED_MDC
:
1393
case
PGPTAG_MDC
:
1394
case
PGPTAG_PRIVATE_60
:
1395
case
PGPTAG_PRIVATE_62
:
1396
case
PGPTAG_CONTROL
:
1397
default
:
1398
rc = 0;
1399
break
;
1400
}
1401
1402
return
rc;
1403
}
1404
1405
#define CRC24_INIT 0xb704ce
1406
#define CRC24_POLY 0x1864cfb
1407
1414
/*@unused@*/
static
inline
1415
unsigned
int
pgpCRC
(
const
byte
*octets,
size_t
len)
1416
/*@*/
1417
{
1418
unsigned
int
crc =
CRC24_INIT
;
1419
int
i;
1420
1421
while
(len--) {
1422
/*@-boundsread@*/
1423
crc ^= (*octets++) << 16;
1424
/*@=boundsread@*/
1425
for
(i = 0; i < 8; i++) {
1426
crc <<= 1;
1427
if
(crc & 0x1000000)
1428
crc ^=
CRC24_POLY
;
1429
}
1430
}
1431
return
crc & 0xffffff;
1432
}
1433
1439
/*@only@*/
1440
DIGEST_CTX
rpmDigestDup
(DIGEST_CTX octx)
1441
/*@*/
;
1442
1450
/*@only@*/
/*@null@*/
1451
DIGEST_CTX
rpmDigestInit
(
pgpHashAlgo
hashalgo,
rpmDigestFlags
flags)
1452
/*@*/
;
1453
1461
int
rpmDigestUpdate
(
/*@null@*/
DIGEST_CTX ctx,
const
void
* data,
size_t
len)
1462
/*@modifies ctx @*/
;
1463
1475
int
rpmDigestFinal
(
/*@only@*/
/*@null@*/
DIGEST_CTX ctx,
1476
/*@null@*/
/*@out@*/
void
* datap,
1477
/*@null@*/
/*@out@*/
size_t
* lenp,
int
asAscii)
1478
/*@modifies *datap, *lenp @*/
;
1479
1480
#ifdef __cplusplus
1481
}
1482
#endif
1483
/*@=fcnuse@*/
1484
1485
#endif
/* H_RPMPGP */
Generated on Tue Aug 28 2012 18:13:48 for rpm by
1.8.2