Take the internal functions and definitions back out of the implementation
namespace: :g/\<__ops/s//pgp/g :g/\<__OPS/s//__PGP/g :g/\<OPS/s//PGP/g No functional change, regression tests complete successfully.
This commit is contained in:
parent
3184965a25
commit
fc1f8641b7
126
crypto/external/bsd/netpgp/dist/src/lib/compress.c
vendored
126
crypto/external/bsd/netpgp/dist/src/lib/compress.c
vendored
@ -57,7 +57,7 @@
|
||||
|
||||
#if defined(__NetBSD__)
|
||||
__COPYRIGHT("@(#) Copyright (c) 2009 The NetBSD Foundation, Inc. All rights reserved.");
|
||||
__RCSID("$NetBSD: compress.c,v 1.18 2010/10/31 18:31:03 agc Exp $");
|
||||
__RCSID("$NetBSD: compress.c,v 1.19 2010/11/07 08:39:59 agc Exp $");
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_ZLIB_H
|
||||
@ -80,8 +80,8 @@ __RCSID("$NetBSD: compress.c,v 1.18 2010/10/31 18:31:03 agc Exp $");
|
||||
#define DECOMPRESS_BUFFER 1024
|
||||
|
||||
typedef struct {
|
||||
__ops_compression_type_t type;
|
||||
__ops_region_t *region;
|
||||
pgp_compression_type_t type;
|
||||
pgp_region_t *region;
|
||||
uint8_t in[DECOMPRESS_BUFFER];
|
||||
uint8_t out[DECOMPRESS_BUFFER];
|
||||
z_stream zstream;/* ZIP and ZLIB */
|
||||
@ -91,8 +91,8 @@ typedef struct {
|
||||
|
||||
#ifdef HAVE_BZLIB_H
|
||||
typedef struct {
|
||||
__ops_compression_type_t type;
|
||||
__ops_region_t *region;
|
||||
pgp_compression_type_t type;
|
||||
pgp_region_t *region;
|
||||
char in[DECOMPRESS_BUFFER];
|
||||
char out[DECOMPRESS_BUFFER];
|
||||
bz_stream bzstream; /* BZIP2 */
|
||||
@ -113,16 +113,16 @@ typedef struct {
|
||||
*/
|
||||
static int
|
||||
zlib_compressed_data_reader(void *dest, size_t length,
|
||||
__ops_error_t **errors,
|
||||
__ops_reader_t *readinfo,
|
||||
__ops_cbdata_t *cbinfo)
|
||||
pgp_error_t **errors,
|
||||
pgp_reader_t *readinfo,
|
||||
pgp_cbdata_t *cbinfo)
|
||||
{
|
||||
z_decompress_t *z = __ops_reader_get_arg(readinfo);
|
||||
z_decompress_t *z = pgp_reader_get_arg(readinfo);
|
||||
size_t len;
|
||||
size_t cc;
|
||||
char *cdest = dest;
|
||||
|
||||
if (z->type != OPS_C_ZIP && z->type != OPS_C_ZLIB) {
|
||||
if (z->type != PGP_C_ZIP && z->type != PGP_C_ZLIB) {
|
||||
(void) fprintf(stderr,
|
||||
"zlib_compressed_data_reader: weird type %d\n",
|
||||
z->type);
|
||||
@ -134,7 +134,7 @@ zlib_compressed_data_reader(void *dest, size_t length,
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (__ops_get_debug_level(__FILE__)) {
|
||||
if (pgp_get_debug_level(__FILE__)) {
|
||||
(void) fprintf(stderr,
|
||||
"zlib_compressed_data_reader: length %" PRIsize "d\n",
|
||||
length);
|
||||
@ -142,7 +142,7 @@ zlib_compressed_data_reader(void *dest, size_t length,
|
||||
|
||||
if (z->region->readc == z->region->length) {
|
||||
if (z->inflate_ret != Z_STREAM_END) {
|
||||
OPS_ERROR(cbinfo->errors, OPS_E_P_DECOMPRESSION_ERROR,
|
||||
PGP_ERROR(cbinfo->errors, PGP_E_P_DECOMPRESSION_ERROR,
|
||||
"Compressed data didn't end when region ended.");
|
||||
}
|
||||
}
|
||||
@ -164,7 +164,7 @@ zlib_compressed_data_reader(void *dest, size_t length,
|
||||
} else {
|
||||
n = sizeof(z->in);
|
||||
}
|
||||
if (!__ops_stacked_limited_read(z->in, n,
|
||||
if (!pgp_stacked_limited_read(z->in, n,
|
||||
z->region,
|
||||
errors, readinfo, cbinfo)) {
|
||||
return -1;
|
||||
@ -178,14 +178,14 @@ zlib_compressed_data_reader(void *dest, size_t length,
|
||||
if (ret == Z_STREAM_END) {
|
||||
if (!z->region->indeterminate &&
|
||||
z->region->readc != z->region->length) {
|
||||
OPS_ERROR(cbinfo->errors,
|
||||
OPS_E_P_DECOMPRESSION_ERROR,
|
||||
PGP_ERROR(cbinfo->errors,
|
||||
PGP_E_P_DECOMPRESSION_ERROR,
|
||||
"Compressed stream ended before packet end.");
|
||||
}
|
||||
} else if (ret != Z_OK) {
|
||||
(void) fprintf(stderr, "ret=%d\n", ret);
|
||||
OPS_ERROR(cbinfo->errors,
|
||||
OPS_E_P_DECOMPRESSION_ERROR, z->zstream.msg);
|
||||
PGP_ERROR(cbinfo->errors,
|
||||
PGP_E_P_DECOMPRESSION_ERROR, z->zstream.msg);
|
||||
}
|
||||
z->inflate_ret = ret;
|
||||
}
|
||||
@ -208,16 +208,16 @@ zlib_compressed_data_reader(void *dest, size_t length,
|
||||
/* \todo remove code duplication between this and zlib_compressed_data_reader */
|
||||
static int
|
||||
bzip2_compressed_data_reader(void *dest, size_t length,
|
||||
__ops_error_t **errors,
|
||||
__ops_reader_t *readinfo,
|
||||
__ops_cbdata_t *cbinfo)
|
||||
pgp_error_t **errors,
|
||||
pgp_reader_t *readinfo,
|
||||
pgp_cbdata_t *cbinfo)
|
||||
{
|
||||
bz_decompress_t *bz = __ops_reader_get_arg(readinfo);
|
||||
bz_decompress_t *bz = pgp_reader_get_arg(readinfo);
|
||||
size_t len;
|
||||
size_t cc;
|
||||
char *cdest = dest;
|
||||
|
||||
if (bz->type != OPS_C_BZIP2) {
|
||||
if (bz->type != PGP_C_BZIP2) {
|
||||
(void) fprintf(stderr, "Weird type %d\n", bz->type);
|
||||
return 0;
|
||||
}
|
||||
@ -228,7 +228,7 @@ bzip2_compressed_data_reader(void *dest, size_t length,
|
||||
}
|
||||
if (bz->region->readc == bz->region->length) {
|
||||
if (bz->inflate_ret != BZ_STREAM_END) {
|
||||
OPS_ERROR(cbinfo->errors, OPS_E_P_DECOMPRESSION_ERROR,
|
||||
PGP_ERROR(cbinfo->errors, PGP_E_P_DECOMPRESSION_ERROR,
|
||||
"Compressed data didn't end when region ended.");
|
||||
}
|
||||
}
|
||||
@ -249,7 +249,7 @@ bzip2_compressed_data_reader(void *dest, size_t length,
|
||||
} else
|
||||
n = sizeof(bz->in);
|
||||
|
||||
if (!__ops_stacked_limited_read(
|
||||
if (!pgp_stacked_limited_read(
|
||||
(uint8_t *) bz->in,
|
||||
n, bz->region,
|
||||
errors, readinfo, cbinfo))
|
||||
@ -264,12 +264,12 @@ bzip2_compressed_data_reader(void *dest, size_t length,
|
||||
if (ret == BZ_STREAM_END) {
|
||||
if (!bz->region->indeterminate &&
|
||||
bz->region->readc != bz->region->length)
|
||||
OPS_ERROR(cbinfo->errors,
|
||||
OPS_E_P_DECOMPRESSION_ERROR,
|
||||
PGP_ERROR(cbinfo->errors,
|
||||
PGP_E_P_DECOMPRESSION_ERROR,
|
||||
"Compressed stream ended before packet end.");
|
||||
} else if (ret != BZ_OK) {
|
||||
OPS_ERROR_1(cbinfo->errors,
|
||||
OPS_E_P_DECOMPRESSION_ERROR,
|
||||
PGP_ERROR_1(cbinfo->errors,
|
||||
PGP_E_P_DECOMPRESSION_ERROR,
|
||||
"Invalid return %d from BZ2_bzDecompress", ret);
|
||||
}
|
||||
bz->inflate_ret = ret;
|
||||
@ -299,8 +299,8 @@ bzip2_compressed_data_reader(void *dest, size_t length,
|
||||
*/
|
||||
|
||||
int
|
||||
__ops_decompress(__ops_region_t *region, __ops_stream_t *stream,
|
||||
__ops_compression_type_t type)
|
||||
pgp_decompress(pgp_region_t *region, pgp_stream_t *stream,
|
||||
pgp_compression_type_t type)
|
||||
{
|
||||
z_decompress_t z;
|
||||
#ifdef HAVE_BZLIB_H
|
||||
@ -310,8 +310,8 @@ __ops_decompress(__ops_region_t *region, __ops_stream_t *stream,
|
||||
int ret;
|
||||
|
||||
switch (type) {
|
||||
case OPS_C_ZIP:
|
||||
case OPS_C_ZLIB:
|
||||
case PGP_C_ZIP:
|
||||
case PGP_C_ZLIB:
|
||||
(void) memset(&z, 0x0, sizeof(z));
|
||||
|
||||
z.region = region;
|
||||
@ -328,7 +328,7 @@ __ops_decompress(__ops_region_t *region, __ops_stream_t *stream,
|
||||
break;
|
||||
|
||||
#ifdef HAVE_BZLIB_H
|
||||
case OPS_C_BZIP2:
|
||||
case PGP_C_BZIP2:
|
||||
(void) memset(&bz, 0x0, sizeof(bz));
|
||||
|
||||
bz.region = region;
|
||||
@ -346,72 +346,72 @@ __ops_decompress(__ops_region_t *region, __ops_stream_t *stream,
|
||||
break;
|
||||
|
||||
default:
|
||||
OPS_ERROR_1(&stream->errors,
|
||||
OPS_E_ALG_UNSUPPORTED_COMPRESS_ALG,
|
||||
PGP_ERROR_1(&stream->errors,
|
||||
PGP_E_ALG_UNSUPPORTED_COMPRESS_ALG,
|
||||
"Compression algorithm %d is not yet supported", type);
|
||||
return 0;
|
||||
}
|
||||
|
||||
switch (type) {
|
||||
case OPS_C_ZIP:
|
||||
case PGP_C_ZIP:
|
||||
/* LINTED */ /* this is a lint problem in zlib.h header */
|
||||
ret = (int)inflateInit2(&z.zstream, -15);
|
||||
break;
|
||||
|
||||
case OPS_C_ZLIB:
|
||||
case PGP_C_ZLIB:
|
||||
/* LINTED */ /* this is a lint problem in zlib.h header */
|
||||
ret = (int)inflateInit(&z.zstream);
|
||||
break;
|
||||
|
||||
#ifdef HAVE_BZLIB_H
|
||||
case OPS_C_BZIP2:
|
||||
case PGP_C_BZIP2:
|
||||
ret = BZ2_bzDecompressInit(&bz.bzstream, 1, 0);
|
||||
break;
|
||||
#endif
|
||||
|
||||
default:
|
||||
OPS_ERROR_1(&stream->errors,
|
||||
OPS_E_ALG_UNSUPPORTED_COMPRESS_ALG,
|
||||
PGP_ERROR_1(&stream->errors,
|
||||
PGP_E_ALG_UNSUPPORTED_COMPRESS_ALG,
|
||||
"Compression algorithm %d is not yet supported", type);
|
||||
return 0;
|
||||
}
|
||||
|
||||
switch (type) {
|
||||
case OPS_C_ZIP:
|
||||
case OPS_C_ZLIB:
|
||||
case PGP_C_ZIP:
|
||||
case PGP_C_ZLIB:
|
||||
if (ret != Z_OK) {
|
||||
OPS_ERROR_1(&stream->errors,
|
||||
OPS_E_P_DECOMPRESSION_ERROR,
|
||||
PGP_ERROR_1(&stream->errors,
|
||||
PGP_E_P_DECOMPRESSION_ERROR,
|
||||
"Cannot initialise ZIP or ZLIB stream for decompression: error=%d", ret);
|
||||
return 0;
|
||||
}
|
||||
__ops_reader_push(stream, zlib_compressed_data_reader,
|
||||
pgp_reader_push(stream, zlib_compressed_data_reader,
|
||||
NULL, &z);
|
||||
break;
|
||||
|
||||
#ifdef HAVE_BZLIB_H
|
||||
case OPS_C_BZIP2:
|
||||
case PGP_C_BZIP2:
|
||||
if (ret != BZ_OK) {
|
||||
OPS_ERROR_1(&stream->errors,
|
||||
OPS_E_P_DECOMPRESSION_ERROR,
|
||||
PGP_ERROR_1(&stream->errors,
|
||||
PGP_E_P_DECOMPRESSION_ERROR,
|
||||
"Cannot initialise BZIP2 stream for decompression: error=%d", ret);
|
||||
return 0;
|
||||
}
|
||||
__ops_reader_push(stream, bzip2_compressed_data_reader,
|
||||
pgp_reader_push(stream, bzip2_compressed_data_reader,
|
||||
NULL, &bz);
|
||||
break;
|
||||
#endif
|
||||
|
||||
default:
|
||||
OPS_ERROR_1(&stream->errors,
|
||||
OPS_E_ALG_UNSUPPORTED_COMPRESS_ALG,
|
||||
PGP_ERROR_1(&stream->errors,
|
||||
PGP_E_ALG_UNSUPPORTED_COMPRESS_ALG,
|
||||
"Compression algorithm %d is not yet supported", type);
|
||||
return 0;
|
||||
}
|
||||
|
||||
ret = __ops_parse(stream, !printerrors);
|
||||
ret = pgp_parse(stream, !printerrors);
|
||||
|
||||
__ops_reader_pop(stream);
|
||||
pgp_reader_pop(stream);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@ -426,7 +426,7 @@ __ops_decompress(__ops_region_t *region, __ops_stream_t *stream,
|
||||
*/
|
||||
|
||||
unsigned
|
||||
__ops_writez(__ops_output_t *out, const uint8_t *data, const unsigned len)
|
||||
pgp_writez(pgp_output_t *out, const uint8_t *data, const unsigned len)
|
||||
{
|
||||
compress_t *zip;
|
||||
size_t sz_in;
|
||||
@ -439,7 +439,7 @@ __ops_writez(__ops_output_t *out, const uint8_t *data, const unsigned len)
|
||||
* levels */
|
||||
|
||||
if ((zip = calloc(1, sizeof(*zip))) == NULL) {
|
||||
(void) fprintf(stderr, "__ops_writez: bad alloc\n");
|
||||
(void) fprintf(stderr, "pgp_writez: bad alloc\n");
|
||||
return 0;
|
||||
}
|
||||
zip->stream.zalloc = Z_NULL;
|
||||
@ -450,13 +450,13 @@ __ops_writez(__ops_output_t *out, const uint8_t *data, const unsigned len)
|
||||
|
||||
/* LINTED */ /* this is a lint problem in zlib.h header */
|
||||
if ((int)deflateInit(&zip->stream, level) != Z_OK) {
|
||||
(void) fprintf(stderr, "__ops_writez: can't initialise\n");
|
||||
(void) fprintf(stderr, "pgp_writez: can't initialise\n");
|
||||
return 0;
|
||||
}
|
||||
/* do necessary transformation */
|
||||
/* copy input to maintain const'ness of src */
|
||||
if (zip->src != NULL || zip->dst != NULL) {
|
||||
(void) fprintf(stderr, "__ops_writez: non-null streams\n");
|
||||
(void) fprintf(stderr, "pgp_writez: non-null streams\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -464,13 +464,13 @@ __ops_writez(__ops_output_t *out, const uint8_t *data, const unsigned len)
|
||||
sz_out = ((101 * sz_in) / 100) + 12; /* from zlib webpage */
|
||||
if ((zip->src = calloc(1, sz_in)) == NULL) {
|
||||
free(zip);
|
||||
(void) fprintf(stderr, "__ops_writez: bad alloc2\n");
|
||||
(void) fprintf(stderr, "pgp_writez: bad alloc2\n");
|
||||
return 0;
|
||||
}
|
||||
if ((zip->dst = calloc(1, sz_out)) == NULL) {
|
||||
free(zip->src);
|
||||
free(zip);
|
||||
(void) fprintf(stderr, "__ops_writez: bad alloc3\n");
|
||||
(void) fprintf(stderr, "pgp_writez: bad alloc3\n");
|
||||
return 0;
|
||||
}
|
||||
(void) memcpy(zip->src, data, len);
|
||||
@ -489,10 +489,10 @@ __ops_writez(__ops_output_t *out, const uint8_t *data, const unsigned len)
|
||||
} while (r != Z_STREAM_END);
|
||||
|
||||
/* write it out */
|
||||
ret = __ops_write_ptag(out, OPS_PTAG_CT_COMPRESSED) &&
|
||||
__ops_write_length(out, (unsigned)(zip->stream.total_out + 1))&&
|
||||
__ops_write_scalar(out, OPS_C_ZLIB, 1) &&
|
||||
__ops_write(out, zip->dst, (unsigned)zip->stream.total_out);
|
||||
ret = pgp_write_ptag(out, PGP_PTAG_CT_COMPRESSED) &&
|
||||
pgp_write_length(out, (unsigned)(zip->stream.total_out + 1))&&
|
||||
pgp_write_scalar(out, PGP_C_ZLIB, 1) &&
|
||||
pgp_write(out, zip->dst, (unsigned)zip->stream.total_out);
|
||||
|
||||
free(zip->src);
|
||||
free(zip->dst);
|
||||
|
@ -12,6 +12,9 @@
|
||||
/* Define to 1 if you have the <dlfcn.h> header file. */
|
||||
#undef HAVE_DLFCN_H
|
||||
|
||||
/* Define to 1 if you have the <dmalloc.h> header file. */
|
||||
#undef HAVE_DMALLOC_H
|
||||
|
||||
/* Define to 1 if you have the <errno.h> header file. */
|
||||
#undef HAVE_ERRNO_H
|
||||
|
||||
|
532
crypto/external/bsd/netpgp/dist/src/lib/create.c
vendored
532
crypto/external/bsd/netpgp/dist/src/lib/create.c
vendored
File diff suppressed because it is too large
Load Diff
70
crypto/external/bsd/netpgp/dist/src/lib/create.h
vendored
70
crypto/external/bsd/netpgp/dist/src/lib/create.h
vendored
@ -64,56 +64,56 @@
|
||||
* \ingroup Create
|
||||
* This struct contains the required information about how to write this stream
|
||||
*/
|
||||
struct __ops_output_t {
|
||||
__ops_writer_t writer;
|
||||
__ops_error_t *errors; /* error stack */
|
||||
struct pgp_output_t {
|
||||
pgp_writer_t writer;
|
||||
pgp_error_t *errors; /* error stack */
|
||||
};
|
||||
|
||||
__ops_output_t *__ops_output_new(void);
|
||||
void __ops_output_delete(__ops_output_t *);
|
||||
pgp_output_t *pgp_output_new(void);
|
||||
void pgp_output_delete(pgp_output_t *);
|
||||
|
||||
int __ops_filewrite(const char *, const char *, const size_t, const unsigned);
|
||||
int pgp_filewrite(const char *, const char *, const size_t, const unsigned);
|
||||
|
||||
void __ops_build_pubkey(__ops_memory_t *, const __ops_pubkey_t *, unsigned);
|
||||
void pgp_build_pubkey(pgp_memory_t *, const pgp_pubkey_t *, unsigned);
|
||||
|
||||
unsigned __ops_calc_sesskey_checksum(__ops_pk_sesskey_t *, uint8_t *);
|
||||
unsigned __ops_write_struct_userid(__ops_output_t *, const uint8_t *);
|
||||
unsigned __ops_write_ss_header(__ops_output_t *, unsigned, __ops_content_enum);
|
||||
unsigned __ops_write_struct_seckey(const __ops_seckey_t *,
|
||||
unsigned pgp_calc_sesskey_checksum(pgp_pk_sesskey_t *, uint8_t *);
|
||||
unsigned pgp_write_struct_userid(pgp_output_t *, const uint8_t *);
|
||||
unsigned pgp_write_ss_header(pgp_output_t *, unsigned, pgp_content_enum);
|
||||
unsigned pgp_write_struct_seckey(const pgp_seckey_t *,
|
||||
const uint8_t *,
|
||||
const size_t,
|
||||
__ops_output_t *);
|
||||
unsigned __ops_write_one_pass_sig(__ops_output_t *,
|
||||
const __ops_seckey_t *,
|
||||
const __ops_hash_alg_t,
|
||||
const __ops_sig_type_t);
|
||||
unsigned __ops_write_litdata(__ops_output_t *,
|
||||
pgp_output_t *);
|
||||
unsigned pgp_write_one_pass_sig(pgp_output_t *,
|
||||
const pgp_seckey_t *,
|
||||
const pgp_hash_alg_t,
|
||||
const pgp_sig_type_t);
|
||||
unsigned pgp_write_litdata(pgp_output_t *,
|
||||
const uint8_t *,
|
||||
const int,
|
||||
const __ops_litdata_enum);
|
||||
__ops_pk_sesskey_t *__ops_create_pk_sesskey(const __ops_key_t *, const char *);
|
||||
unsigned __ops_write_pk_sesskey(__ops_output_t *, __ops_pk_sesskey_t *);
|
||||
unsigned __ops_write_xfer_pubkey(__ops_output_t *,
|
||||
const __ops_key_t *, const unsigned);
|
||||
unsigned __ops_write_xfer_seckey(__ops_output_t *,
|
||||
const __ops_key_t *,
|
||||
const pgp_litdata_enum);
|
||||
pgp_pk_sesskey_t *pgp_create_pk_sesskey(const pgp_key_t *, const char *);
|
||||
unsigned pgp_write_pk_sesskey(pgp_output_t *, pgp_pk_sesskey_t *);
|
||||
unsigned pgp_write_xfer_pubkey(pgp_output_t *,
|
||||
const pgp_key_t *, const unsigned);
|
||||
unsigned pgp_write_xfer_seckey(pgp_output_t *,
|
||||
const pgp_key_t *,
|
||||
const uint8_t *,
|
||||
const size_t,
|
||||
const unsigned);
|
||||
|
||||
void __ops_fast_create_userid(uint8_t **, uint8_t *);
|
||||
unsigned __ops_write_userid(const uint8_t *, __ops_output_t *);
|
||||
void __ops_fast_create_rsa_pubkey(__ops_pubkey_t *, time_t, BIGNUM *, BIGNUM *);
|
||||
unsigned __ops_write_rsa_pubkey(time_t, const BIGNUM *, const BIGNUM *,
|
||||
__ops_output_t *);
|
||||
void __ops_fast_create_rsa_seckey(__ops_seckey_t *, time_t, BIGNUM *,
|
||||
void pgp_fast_create_userid(uint8_t **, uint8_t *);
|
||||
unsigned pgp_write_userid(const uint8_t *, pgp_output_t *);
|
||||
void pgp_fast_create_rsa_pubkey(pgp_pubkey_t *, time_t, BIGNUM *, BIGNUM *);
|
||||
unsigned pgp_write_rsa_pubkey(time_t, const BIGNUM *, const BIGNUM *,
|
||||
pgp_output_t *);
|
||||
void pgp_fast_create_rsa_seckey(pgp_seckey_t *, time_t, BIGNUM *,
|
||||
BIGNUM *, BIGNUM *, BIGNUM *,
|
||||
BIGNUM *, BIGNUM *);
|
||||
unsigned encode_m_buf(const uint8_t *, size_t, const __ops_pubkey_t *,
|
||||
unsigned encode_m_buf(const uint8_t *, size_t, const pgp_pubkey_t *,
|
||||
uint8_t *);
|
||||
unsigned __ops_fileread_litdata(const char *, const __ops_litdata_enum,
|
||||
__ops_output_t *);
|
||||
unsigned __ops_write_symm_enc_data(const uint8_t *, const int,
|
||||
__ops_output_t *);
|
||||
unsigned pgp_fileread_litdata(const char *, const pgp_litdata_enum,
|
||||
pgp_output_t *);
|
||||
unsigned pgp_write_symm_enc_data(const uint8_t *, const int,
|
||||
pgp_output_t *);
|
||||
|
||||
#endif /* CREATE_H_ */
|
||||
|
234
crypto/external/bsd/netpgp/dist/src/lib/crypto.c
vendored
234
crypto/external/bsd/netpgp/dist/src/lib/crypto.c
vendored
@ -54,7 +54,7 @@
|
||||
|
||||
#if defined(__NetBSD__)
|
||||
__COPYRIGHT("@(#) Copyright (c) 2009 The NetBSD Foundation, Inc. All rights reserved.");
|
||||
__RCSID("$NetBSD: crypto.c,v 1.31 2010/11/07 06:56:52 agc Exp $");
|
||||
__RCSID("$NetBSD: crypto.c,v 1.32 2010/11/07 08:39:59 agc Exp $");
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
@ -84,11 +84,11 @@ __RCSID("$NetBSD: crypto.c,v 1.31 2010/11/07 06:56:52 agc Exp $");
|
||||
\note only RSA at present
|
||||
*/
|
||||
int
|
||||
__ops_decrypt_decode_mpi(uint8_t *buf,
|
||||
pgp_decrypt_decode_mpi(uint8_t *buf,
|
||||
unsigned buflen,
|
||||
const BIGNUM *g_to_k,
|
||||
const BIGNUM *encmpi,
|
||||
const __ops_seckey_t *seckey)
|
||||
const pgp_seckey_t *seckey)
|
||||
{
|
||||
unsigned mpisize;
|
||||
uint8_t encmpibuf[NETPGP_BUFSIZ];
|
||||
@ -104,19 +104,19 @@ __ops_decrypt_decode_mpi(uint8_t *buf,
|
||||
return -1;
|
||||
}
|
||||
switch (seckey->pubkey.alg) {
|
||||
case OPS_PKA_RSA:
|
||||
case PGP_PKA_RSA:
|
||||
BN_bn2bin(encmpi, encmpibuf);
|
||||
if (__ops_get_debug_level(__FILE__)) {
|
||||
if (pgp_get_debug_level(__FILE__)) {
|
||||
hexdump(stderr, "encrypted", encmpibuf, 16);
|
||||
}
|
||||
n = __ops_rsa_private_decrypt(mpibuf, encmpibuf,
|
||||
n = pgp_rsa_private_decrypt(mpibuf, encmpibuf,
|
||||
(unsigned)(BN_num_bits(encmpi) + 7) / 8,
|
||||
&seckey->key.rsa, &seckey->pubkey.key.rsa);
|
||||
if (n == -1) {
|
||||
(void) fprintf(stderr, "ops_rsa_private_decrypt failure\n");
|
||||
return -1;
|
||||
}
|
||||
if (__ops_get_debug_level(__FILE__)) {
|
||||
if (pgp_get_debug_level(__FILE__)) {
|
||||
hexdump(stderr, "decrypted", mpibuf, 16);
|
||||
}
|
||||
if (n <= 0) {
|
||||
@ -138,25 +138,25 @@ __ops_decrypt_decode_mpi(uint8_t *buf,
|
||||
if ((unsigned) (n - i) <= buflen) {
|
||||
(void) memcpy(buf, mpibuf + i, (unsigned)(n - i)); /* XXX - Flexelint */
|
||||
}
|
||||
if (__ops_get_debug_level(__FILE__)) {
|
||||
if (pgp_get_debug_level(__FILE__)) {
|
||||
hexdump(stderr, "decoded m", buf, (size_t)(n - i));
|
||||
}
|
||||
return n - i;
|
||||
case OPS_PKA_DSA:
|
||||
case OPS_PKA_ELGAMAL:
|
||||
case PGP_PKA_DSA:
|
||||
case PGP_PKA_ELGAMAL:
|
||||
(void) BN_bn2bin(g_to_k, gkbuf);
|
||||
(void) BN_bn2bin(encmpi, encmpibuf);
|
||||
if (__ops_get_debug_level(__FILE__)) {
|
||||
if (pgp_get_debug_level(__FILE__)) {
|
||||
hexdump(stderr, "encrypted", encmpibuf, 16);
|
||||
}
|
||||
n = __ops_elgamal_private_decrypt(mpibuf, gkbuf, encmpibuf,
|
||||
n = pgp_elgamal_private_decrypt(mpibuf, gkbuf, encmpibuf,
|
||||
(unsigned)BN_num_bytes(encmpi),
|
||||
&seckey->key.elgamal, &seckey->pubkey.key.elgamal);
|
||||
if (n == -1) {
|
||||
(void) fprintf(stderr, "ops_elgamal_private_decrypt failure\n");
|
||||
return -1;
|
||||
}
|
||||
if (__ops_get_debug_level(__FILE__)) {
|
||||
if (pgp_get_debug_level(__FILE__)) {
|
||||
hexdump(stderr, "decrypted", mpibuf, 16);
|
||||
}
|
||||
if (n <= 0) {
|
||||
@ -180,7 +180,7 @@ __ops_decrypt_decode_mpi(uint8_t *buf,
|
||||
if ((unsigned) (n - i) <= buflen) {
|
||||
(void) memcpy(buf, mpibuf + i, (unsigned)(n - i)); /* XXX - Flexelint */
|
||||
}
|
||||
if (__ops_get_debug_level(__FILE__)) {
|
||||
if (pgp_get_debug_level(__FILE__)) {
|
||||
hexdump(stderr, "decoded m", buf, (size_t)(n - i));
|
||||
}
|
||||
return n - i;
|
||||
@ -195,10 +195,10 @@ __ops_decrypt_decode_mpi(uint8_t *buf,
|
||||
\brief RSA-encrypt an MPI
|
||||
*/
|
||||
unsigned
|
||||
__ops_rsa_encrypt_mpi(const uint8_t *encoded_m_buf,
|
||||
pgp_rsa_encrypt_mpi(const uint8_t *encoded_m_buf,
|
||||
const size_t sz_encoded_m_buf,
|
||||
const __ops_pubkey_t * pubkey,
|
||||
__ops_pk_sesskey_params_t * skp)
|
||||
const pgp_pubkey_t * pubkey,
|
||||
pgp_pk_sesskey_params_t * skp)
|
||||
{
|
||||
|
||||
uint8_t encmpibuf[NETPGP_BUFSIZ];
|
||||
@ -209,10 +209,10 @@ __ops_rsa_encrypt_mpi(const uint8_t *encoded_m_buf,
|
||||
return 0;
|
||||
}
|
||||
|
||||
n = __ops_rsa_public_encrypt(encmpibuf, encoded_m_buf,
|
||||
n = pgp_rsa_public_encrypt(encmpibuf, encoded_m_buf,
|
||||
sz_encoded_m_buf, &pubkey->key.rsa);
|
||||
if (n == -1) {
|
||||
(void) fprintf(stderr, "__ops_rsa_public_encrypt failure\n");
|
||||
(void) fprintf(stderr, "pgp_rsa_public_encrypt failure\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -221,7 +221,7 @@ __ops_rsa_encrypt_mpi(const uint8_t *encoded_m_buf,
|
||||
|
||||
skp->rsa.encrypted_m = BN_bin2bn(encmpibuf, n, NULL);
|
||||
|
||||
if (__ops_get_debug_level(__FILE__)) {
|
||||
if (pgp_get_debug_level(__FILE__)) {
|
||||
hexdump(stderr, "encrypted mpi", encmpibuf, 16);
|
||||
}
|
||||
return 1;
|
||||
@ -232,10 +232,10 @@ __ops_rsa_encrypt_mpi(const uint8_t *encoded_m_buf,
|
||||
\brief Elgamal-encrypt an MPI
|
||||
*/
|
||||
unsigned
|
||||
__ops_elgamal_encrypt_mpi(const uint8_t *encoded_m_buf,
|
||||
pgp_elgamal_encrypt_mpi(const uint8_t *encoded_m_buf,
|
||||
const size_t sz_encoded_m_buf,
|
||||
const __ops_pubkey_t * pubkey,
|
||||
__ops_pk_sesskey_params_t * skp)
|
||||
const pgp_pubkey_t * pubkey,
|
||||
pgp_pk_sesskey_params_t * skp)
|
||||
{
|
||||
|
||||
uint8_t encmpibuf[NETPGP_BUFSIZ];
|
||||
@ -247,10 +247,10 @@ __ops_elgamal_encrypt_mpi(const uint8_t *encoded_m_buf,
|
||||
return 0;
|
||||
}
|
||||
|
||||
n = __ops_elgamal_public_encrypt(g_to_k, encmpibuf, encoded_m_buf,
|
||||
n = pgp_elgamal_public_encrypt(g_to_k, encmpibuf, encoded_m_buf,
|
||||
sz_encoded_m_buf, &pubkey->key.elgamal);
|
||||
if (n == -1) {
|
||||
(void) fprintf(stderr, "__ops_elgamal_public_encrypt failure\n");
|
||||
(void) fprintf(stderr, "pgp_elgamal_public_encrypt failure\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -260,28 +260,28 @@ __ops_elgamal_encrypt_mpi(const uint8_t *encoded_m_buf,
|
||||
skp->elgamal.g_to_k = BN_bin2bn(g_to_k, n / 2, NULL);
|
||||
skp->elgamal.encrypted_m = BN_bin2bn(encmpibuf, n / 2, NULL);
|
||||
|
||||
if (__ops_get_debug_level(__FILE__)) {
|
||||
if (pgp_get_debug_level(__FILE__)) {
|
||||
hexdump(stderr, "encrypted mpi", encmpibuf, 16);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
static __ops_cb_ret_t
|
||||
write_parsed_cb(const __ops_packet_t *pkt, __ops_cbdata_t *cbinfo)
|
||||
static pgp_cb_ret_t
|
||||
write_parsed_cb(const pgp_packet_t *pkt, pgp_cbdata_t *cbinfo)
|
||||
{
|
||||
const __ops_contents_t *content = &pkt->u;
|
||||
const pgp_contents_t *content = &pkt->u;
|
||||
|
||||
if (__ops_get_debug_level(__FILE__)) {
|
||||
if (pgp_get_debug_level(__FILE__)) {
|
||||
printf("write_parsed_cb: ");
|
||||
__ops_print_packet(&cbinfo->printstate, pkt);
|
||||
pgp_print_packet(&cbinfo->printstate, pkt);
|
||||
}
|
||||
if (pkt->tag != OPS_PTAG_CT_UNARMOURED_TEXT && cbinfo->printstate.skipping) {
|
||||
if (pkt->tag != PGP_PTAG_CT_UNARMOURED_TEXT && cbinfo->printstate.skipping) {
|
||||
puts("...end of skip");
|
||||
cbinfo->printstate.skipping = 0;
|
||||
}
|
||||
switch (pkt->tag) {
|
||||
case OPS_PTAG_CT_UNARMOURED_TEXT:
|
||||
printf("OPS_PTAG_CT_UNARMOURED_TEXT\n");
|
||||
case PGP_PTAG_CT_UNARMOURED_TEXT:
|
||||
printf("PGP_PTAG_CT_UNARMOURED_TEXT\n");
|
||||
if (!cbinfo->printstate.skipping) {
|
||||
puts("Skipping...");
|
||||
cbinfo->printstate.skipping = 1;
|
||||
@ -290,38 +290,38 @@ write_parsed_cb(const __ops_packet_t *pkt, __ops_cbdata_t *cbinfo)
|
||||
content->unarmoured_text.length, stdout);
|
||||
break;
|
||||
|
||||
case OPS_PTAG_CT_PK_SESSION_KEY:
|
||||
return __ops_pk_sesskey_cb(pkt, cbinfo);
|
||||
case PGP_PTAG_CT_PK_SESSION_KEY:
|
||||
return pgp_pk_sesskey_cb(pkt, cbinfo);
|
||||
|
||||
case OPS_GET_SECKEY:
|
||||
case PGP_GET_SECKEY:
|
||||
if (cbinfo->sshseckey) {
|
||||
*content->get_seckey.seckey = cbinfo->sshseckey;
|
||||
return OPS_KEEP_MEMORY;
|
||||
return PGP_KEEP_MEMORY;
|
||||
}
|
||||
return __ops_get_seckey_cb(pkt, cbinfo);
|
||||
return pgp_get_seckey_cb(pkt, cbinfo);
|
||||
|
||||
case OPS_GET_PASSPHRASE:
|
||||
case PGP_GET_PASSPHRASE:
|
||||
return cbinfo->cryptinfo.getpassphrase(pkt, cbinfo);
|
||||
|
||||
case OPS_PTAG_CT_LITDATA_BODY:
|
||||
return __ops_litdata_cb(pkt, cbinfo);
|
||||
case PGP_PTAG_CT_LITDATA_BODY:
|
||||
return pgp_litdata_cb(pkt, cbinfo);
|
||||
|
||||
case OPS_PTAG_CT_ARMOUR_HEADER:
|
||||
case OPS_PTAG_CT_ARMOUR_TRAILER:
|
||||
case OPS_PTAG_CT_ENCRYPTED_PK_SESSION_KEY:
|
||||
case OPS_PTAG_CT_COMPRESSED:
|
||||
case OPS_PTAG_CT_LITDATA_HEADER:
|
||||
case OPS_PTAG_CT_SE_IP_DATA_BODY:
|
||||
case OPS_PTAG_CT_SE_IP_DATA_HEADER:
|
||||
case OPS_PTAG_CT_SE_DATA_BODY:
|
||||
case OPS_PTAG_CT_SE_DATA_HEADER:
|
||||
case PGP_PTAG_CT_ARMOUR_HEADER:
|
||||
case PGP_PTAG_CT_ARMOUR_TRAILER:
|
||||
case PGP_PTAG_CT_ENCRYPTED_PK_SESSION_KEY:
|
||||
case PGP_PTAG_CT_COMPRESSED:
|
||||
case PGP_PTAG_CT_LITDATA_HEADER:
|
||||
case PGP_PTAG_CT_SE_IP_DATA_BODY:
|
||||
case PGP_PTAG_CT_SE_IP_DATA_HEADER:
|
||||
case PGP_PTAG_CT_SE_DATA_BODY:
|
||||
case PGP_PTAG_CT_SE_DATA_HEADER:
|
||||
/* Ignore these packets */
|
||||
/* They're handled in __ops_parse_packet() */
|
||||
/* They're handled in pgp_parse_packet() */
|
||||
/* and nothing else needs to be done */
|
||||
break;
|
||||
|
||||
default:
|
||||
if (__ops_get_debug_level(__FILE__)) {
|
||||
if (pgp_get_debug_level(__FILE__)) {
|
||||
fprintf(stderr, "Unexpected packet tag=%d (0x%x)\n",
|
||||
pkt->tag,
|
||||
pkt->tag);
|
||||
@ -329,7 +329,7 @@ write_parsed_cb(const __ops_packet_t *pkt, __ops_cbdata_t *cbinfo)
|
||||
break;
|
||||
}
|
||||
|
||||
return OPS_RELEASE_MEMORY;
|
||||
return PGP_RELEASE_MEMORY;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -343,85 +343,85 @@ Encrypt a file
|
||||
\return 1 if OK; else 0
|
||||
*/
|
||||
unsigned
|
||||
__ops_encrypt_file(__ops_io_t *io,
|
||||
pgp_encrypt_file(pgp_io_t *io,
|
||||
const char *infile,
|
||||
const char *outfile,
|
||||
const __ops_key_t *key,
|
||||
const pgp_key_t *key,
|
||||
const unsigned use_armour,
|
||||
const unsigned allow_overwrite,
|
||||
const char *cipher)
|
||||
{
|
||||
__ops_output_t *output;
|
||||
__ops_memory_t *inmem;
|
||||
pgp_output_t *output;
|
||||
pgp_memory_t *inmem;
|
||||
int fd_out;
|
||||
|
||||
__OPS_USED(io);
|
||||
inmem = __ops_memory_new();
|
||||
if (!__ops_mem_readfile(inmem, infile)) {
|
||||
__PGP_USED(io);
|
||||
inmem = pgp_memory_new();
|
||||
if (!pgp_mem_readfile(inmem, infile)) {
|
||||
return 0;
|
||||
}
|
||||
fd_out = __ops_setup_file_write(&output, outfile, allow_overwrite);
|
||||
fd_out = pgp_setup_file_write(&output, outfile, allow_overwrite);
|
||||
if (fd_out < 0) {
|
||||
__ops_memory_free(inmem);
|
||||
pgp_memory_free(inmem);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* set armoured/not armoured here */
|
||||
if (use_armour) {
|
||||
__ops_writer_push_armor_msg(output);
|
||||
pgp_writer_push_armor_msg(output);
|
||||
}
|
||||
|
||||
/* Push the encrypted writer */
|
||||
if (!__ops_push_enc_se_ip(output, key, cipher)) {
|
||||
__ops_memory_free(inmem);
|
||||
if (!pgp_push_enc_se_ip(output, key, cipher)) {
|
||||
pgp_memory_free(inmem);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* This does the writing */
|
||||
__ops_write(output, __ops_mem_data(inmem), (unsigned)__ops_mem_len(inmem));
|
||||
pgp_write(output, pgp_mem_data(inmem), (unsigned)pgp_mem_len(inmem));
|
||||
|
||||
/* tidy up */
|
||||
__ops_memory_free(inmem);
|
||||
__ops_teardown_file_write(output, fd_out);
|
||||
pgp_memory_free(inmem);
|
||||
pgp_teardown_file_write(output, fd_out);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* encrypt the contents of the input buffer, and return the mem structure */
|
||||
__ops_memory_t *
|
||||
__ops_encrypt_buf(__ops_io_t *io,
|
||||
pgp_memory_t *
|
||||
pgp_encrypt_buf(pgp_io_t *io,
|
||||
const void *input,
|
||||
const size_t insize,
|
||||
const __ops_key_t *pubkey,
|
||||
const pgp_key_t *pubkey,
|
||||
const unsigned use_armour,
|
||||
const char *cipher)
|
||||
{
|
||||
__ops_output_t *output;
|
||||
__ops_memory_t *outmem;
|
||||
pgp_output_t *output;
|
||||
pgp_memory_t *outmem;
|
||||
|
||||
__OPS_USED(io);
|
||||
__PGP_USED(io);
|
||||
if (input == NULL) {
|
||||
(void) fprintf(io->errs,
|
||||
"__ops_encrypt_buf: null memory\n");
|
||||
"pgp_encrypt_buf: null memory\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
__ops_setup_memory_write(&output, &outmem, insize);
|
||||
pgp_setup_memory_write(&output, &outmem, insize);
|
||||
|
||||
/* set armoured/not armoured here */
|
||||
if (use_armour) {
|
||||
__ops_writer_push_armor_msg(output);
|
||||
pgp_writer_push_armor_msg(output);
|
||||
}
|
||||
|
||||
/* Push the encrypted writer */
|
||||
__ops_push_enc_se_ip(output, pubkey, cipher);
|
||||
pgp_push_enc_se_ip(output, pubkey, cipher);
|
||||
|
||||
/* This does the writing */
|
||||
__ops_write(output, input, (unsigned)insize);
|
||||
pgp_write(output, input, (unsigned)insize);
|
||||
|
||||
/* tidy up */
|
||||
__ops_writer_close(output);
|
||||
__ops_output_delete(output);
|
||||
pgp_writer_close(output);
|
||||
pgp_output_delete(output);
|
||||
|
||||
return outmem;
|
||||
}
|
||||
@ -438,25 +438,25 @@ __ops_encrypt_buf(__ops_io_t *io,
|
||||
*/
|
||||
|
||||
unsigned
|
||||
__ops_decrypt_file(__ops_io_t *io,
|
||||
pgp_decrypt_file(pgp_io_t *io,
|
||||
const char *infile,
|
||||
const char *outfile,
|
||||
__ops_keyring_t *secring,
|
||||
__ops_keyring_t *pubring,
|
||||
pgp_keyring_t *secring,
|
||||
pgp_keyring_t *pubring,
|
||||
const unsigned use_armour,
|
||||
const unsigned allow_overwrite,
|
||||
const unsigned sshkeys,
|
||||
void *passfp,
|
||||
__ops_cbfunc_t *getpassfunc)
|
||||
pgp_cbfunc_t *getpassfunc)
|
||||
{
|
||||
__ops_stream_t *parse = NULL;
|
||||
pgp_stream_t *parse = NULL;
|
||||
const int printerrors = 1;
|
||||
char *filename = NULL;
|
||||
int fd_in;
|
||||
int fd_out;
|
||||
|
||||
/* setup for reading from given input file */
|
||||
fd_in = __ops_setup_file_read(io, &parse, infile,
|
||||
fd_in = pgp_setup_file_read(io, &parse, infile,
|
||||
NULL,
|
||||
write_parsed_cb,
|
||||
0);
|
||||
@ -466,11 +466,11 @@ __ops_decrypt_file(__ops_io_t *io,
|
||||
}
|
||||
/* setup output filename */
|
||||
if (outfile) {
|
||||
fd_out = __ops_setup_file_write(&parse->cbinfo.output, outfile,
|
||||
fd_out = pgp_setup_file_write(&parse->cbinfo.output, outfile,
|
||||
allow_overwrite);
|
||||
if (fd_out < 0) {
|
||||
perror(outfile);
|
||||
__ops_teardown_file_read(parse, fd_in);
|
||||
pgp_teardown_file_read(parse, fd_in);
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
@ -490,12 +490,12 @@ __ops_decrypt_file(__ops_io_t *io,
|
||||
filename[filenamelen] = 0x0;
|
||||
}
|
||||
|
||||
fd_out = __ops_setup_file_write(&parse->cbinfo.output,
|
||||
fd_out = pgp_setup_file_write(&parse->cbinfo.output,
|
||||
filename, allow_overwrite);
|
||||
if (fd_out < 0) {
|
||||
perror(filename);
|
||||
free(filename);
|
||||
__ops_teardown_file_read(parse, fd_in);
|
||||
pgp_teardown_file_read(parse, fd_in);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@ -513,61 +513,61 @@ __ops_decrypt_file(__ops_io_t *io,
|
||||
|
||||
/* Set up armour/passphrase options */
|
||||
if (use_armour) {
|
||||
__ops_reader_push_dearmour(parse);
|
||||
pgp_reader_push_dearmour(parse);
|
||||
}
|
||||
|
||||
/* Do it */
|
||||
__ops_parse(parse, printerrors);
|
||||
pgp_parse(parse, printerrors);
|
||||
|
||||
/* Unsetup */
|
||||
if (use_armour) {
|
||||
__ops_reader_pop_dearmour(parse);
|
||||
pgp_reader_pop_dearmour(parse);
|
||||
}
|
||||
|
||||
if (filename) {
|
||||
__ops_teardown_file_write(parse->cbinfo.output, fd_out);
|
||||
pgp_teardown_file_write(parse->cbinfo.output, fd_out);
|
||||
free(filename);
|
||||
}
|
||||
__ops_teardown_file_read(parse, fd_in);
|
||||
pgp_teardown_file_read(parse, fd_in);
|
||||
/* \todo cleardown crypt */
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* decrypt an area of memory */
|
||||
__ops_memory_t *
|
||||
__ops_decrypt_buf(__ops_io_t *io,
|
||||
pgp_memory_t *
|
||||
pgp_decrypt_buf(pgp_io_t *io,
|
||||
const void *input,
|
||||
const size_t insize,
|
||||
__ops_keyring_t *secring,
|
||||
__ops_keyring_t *pubring,
|
||||
pgp_keyring_t *secring,
|
||||
pgp_keyring_t *pubring,
|
||||
const unsigned use_armour,
|
||||
const unsigned sshkeys,
|
||||
void *passfp,
|
||||
__ops_cbfunc_t *getpassfunc)
|
||||
pgp_cbfunc_t *getpassfunc)
|
||||
{
|
||||
__ops_stream_t *parse = NULL;
|
||||
__ops_memory_t *outmem;
|
||||
__ops_memory_t *inmem;
|
||||
pgp_stream_t *parse = NULL;
|
||||
pgp_memory_t *outmem;
|
||||
pgp_memory_t *inmem;
|
||||
const int printerrors = 1;
|
||||
|
||||
if (input == NULL) {
|
||||
(void) fprintf(io->errs,
|
||||
"__ops_encrypt_buf: null memory\n");
|
||||
"pgp_encrypt_buf: null memory\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
inmem = __ops_memory_new();
|
||||
__ops_memory_add(inmem, input, insize);
|
||||
inmem = pgp_memory_new();
|
||||
pgp_memory_add(inmem, input, insize);
|
||||
|
||||
/* set up to read from memory */
|
||||
__ops_setup_memory_read(io, &parse, inmem,
|
||||
pgp_setup_memory_read(io, &parse, inmem,
|
||||
NULL,
|
||||
write_parsed_cb,
|
||||
0);
|
||||
|
||||
/* setup for writing decrypted contents to given output file */
|
||||
__ops_setup_memory_write(&parse->cbinfo.output, &outmem, insize);
|
||||
pgp_setup_memory_write(&parse->cbinfo.output, &outmem, insize);
|
||||
|
||||
/* setup keyring and passphrase callback */
|
||||
parse->cbinfo.cryptinfo.secring = secring;
|
||||
@ -578,24 +578,24 @@ __ops_decrypt_buf(__ops_io_t *io,
|
||||
|
||||
/* Set up armour/passphrase options */
|
||||
if (use_armour) {
|
||||
__ops_reader_push_dearmour(parse);
|
||||
pgp_reader_push_dearmour(parse);
|
||||
}
|
||||
|
||||
/* Do it */
|
||||
__ops_parse(parse, printerrors);
|
||||
pgp_parse(parse, printerrors);
|
||||
|
||||
/* Unsetup */
|
||||
if (use_armour) {
|
||||
__ops_reader_pop_dearmour(parse);
|
||||
pgp_reader_pop_dearmour(parse);
|
||||
}
|
||||
|
||||
/* tidy up */
|
||||
__ops_teardown_memory_read(parse, inmem);
|
||||
__ops_memory_release(inmem);
|
||||
pgp_teardown_memory_read(parse, inmem);
|
||||
pgp_memory_release(inmem);
|
||||
free(inmem);
|
||||
|
||||
__ops_writer_close(parse->cbinfo.output);
|
||||
__ops_output_delete(parse->cbinfo.output);
|
||||
pgp_writer_close(parse->cbinfo.output);
|
||||
pgp_output_delete(parse->cbinfo.output);
|
||||
|
||||
return outmem;
|
||||
}
|
||||
|
258
crypto/external/bsd/netpgp/dist/src/lib/crypto.h
vendored
258
crypto/external/bsd/netpgp/dist/src/lib/crypto.h
vendored
@ -60,205 +60,205 @@
|
||||
|
||||
#include <openssl/dsa.h>
|
||||
|
||||
#define OPS_MIN_HASH_SIZE 16
|
||||
#define PGP_MIN_HASH_SIZE 16
|
||||
|
||||
/** _ops_hash_t */
|
||||
struct _ops_hash_t {
|
||||
__ops_hash_alg_t alg; /* algorithm */
|
||||
pgp_hash_alg_t alg; /* algorithm */
|
||||
size_t size; /* size */
|
||||
const char *name; /* what it's known as */
|
||||
int (*init)(__ops_hash_t *);
|
||||
void (*add)(__ops_hash_t *, const uint8_t *, unsigned);
|
||||
unsigned (*finish)(__ops_hash_t *, uint8_t *);
|
||||
int (*init)(pgp_hash_t *);
|
||||
void (*add)(pgp_hash_t *, const uint8_t *, unsigned);
|
||||
unsigned (*finish)(pgp_hash_t *, uint8_t *);
|
||||
void *data; /* blob for data */
|
||||
};
|
||||
|
||||
/** _ops_crypt_t */
|
||||
struct _ops_crypt_t {
|
||||
__ops_symm_alg_t alg;
|
||||
pgp_symm_alg_t alg;
|
||||
size_t blocksize;
|
||||
size_t keysize;
|
||||
void (*set_iv)(__ops_crypt_t *, const uint8_t *);
|
||||
void (*set_crypt_key)(__ops_crypt_t *, const uint8_t *);
|
||||
int (*base_init)(__ops_crypt_t *);
|
||||
void (*decrypt_resync)(__ops_crypt_t *);
|
||||
void (*set_iv)(pgp_crypt_t *, const uint8_t *);
|
||||
void (*set_crypt_key)(pgp_crypt_t *, const uint8_t *);
|
||||
int (*base_init)(pgp_crypt_t *);
|
||||
void (*decrypt_resync)(pgp_crypt_t *);
|
||||
/* encrypt/decrypt one block */
|
||||
void (*block_encrypt)(__ops_crypt_t *, void *, const void *);
|
||||
void (*block_decrypt)(__ops_crypt_t *, void *, const void *);
|
||||
void (*block_encrypt)(pgp_crypt_t *, void *, const void *);
|
||||
void (*block_decrypt)(pgp_crypt_t *, void *, const void *);
|
||||
/* Standard CFB encrypt/decrypt (as used by Sym Enc Int Prot packets) */
|
||||
void (*cfb_encrypt)(__ops_crypt_t *, void *, const void *, size_t);
|
||||
void (*cfb_decrypt)(__ops_crypt_t *, void *, const void *, size_t);
|
||||
void (*decrypt_finish)(__ops_crypt_t *);
|
||||
uint8_t iv[OPS_MAX_BLOCK_SIZE];
|
||||
uint8_t civ[OPS_MAX_BLOCK_SIZE];
|
||||
uint8_t siv[OPS_MAX_BLOCK_SIZE];
|
||||
void (*cfb_encrypt)(pgp_crypt_t *, void *, const void *, size_t);
|
||||
void (*cfb_decrypt)(pgp_crypt_t *, void *, const void *, size_t);
|
||||
void (*decrypt_finish)(pgp_crypt_t *);
|
||||
uint8_t iv[PGP_MAX_BLOCK_SIZE];
|
||||
uint8_t civ[PGP_MAX_BLOCK_SIZE];
|
||||
uint8_t siv[PGP_MAX_BLOCK_SIZE];
|
||||
/* siv is needed for weird v3 resync */
|
||||
uint8_t key[OPS_MAX_KEY_SIZE];
|
||||
uint8_t key[PGP_MAX_KEY_SIZE];
|
||||
int num;
|
||||
/* num is offset - see openssl _encrypt doco */
|
||||
void *encrypt_key;
|
||||
void *decrypt_key;
|
||||
};
|
||||
|
||||
void __ops_crypto_finish(void);
|
||||
void __ops_hash_md5(__ops_hash_t *);
|
||||
void __ops_hash_sha1(__ops_hash_t *);
|
||||
void __ops_hash_sha256(__ops_hash_t *);
|
||||
void __ops_hash_sha512(__ops_hash_t *);
|
||||
void __ops_hash_sha384(__ops_hash_t *);
|
||||
void __ops_hash_sha224(__ops_hash_t *);
|
||||
void __ops_hash_any(__ops_hash_t *, __ops_hash_alg_t);
|
||||
__ops_hash_alg_t __ops_str_to_hash_alg(const char *);
|
||||
const char *__ops_text_from_hash(__ops_hash_t *);
|
||||
unsigned __ops_hash_size(__ops_hash_alg_t);
|
||||
unsigned __ops_hash(uint8_t *, __ops_hash_alg_t, const void *, size_t);
|
||||
void pgp_crypto_finish(void);
|
||||
void pgp_hash_md5(pgp_hash_t *);
|
||||
void pgp_hash_sha1(pgp_hash_t *);
|
||||
void pgp_hash_sha256(pgp_hash_t *);
|
||||
void pgp_hash_sha512(pgp_hash_t *);
|
||||
void pgp_hash_sha384(pgp_hash_t *);
|
||||
void pgp_hash_sha224(pgp_hash_t *);
|
||||
void pgp_hash_any(pgp_hash_t *, pgp_hash_alg_t);
|
||||
pgp_hash_alg_t pgp_str_to_hash_alg(const char *);
|
||||
const char *pgp_text_from_hash(pgp_hash_t *);
|
||||
unsigned pgp_hash_size(pgp_hash_alg_t);
|
||||
unsigned pgp_hash(uint8_t *, pgp_hash_alg_t, const void *, size_t);
|
||||
|
||||
void __ops_hash_add_int(__ops_hash_t *, unsigned, unsigned);
|
||||
void pgp_hash_add_int(pgp_hash_t *, unsigned, unsigned);
|
||||
|
||||
unsigned __ops_dsa_verify(const uint8_t *, size_t,
|
||||
const __ops_dsa_sig_t *,
|
||||
const __ops_dsa_pubkey_t *);
|
||||
unsigned pgp_dsa_verify(const uint8_t *, size_t,
|
||||
const pgp_dsa_sig_t *,
|
||||
const pgp_dsa_pubkey_t *);
|
||||
|
||||
int __ops_rsa_public_decrypt(uint8_t *, const uint8_t *, size_t,
|
||||
const __ops_rsa_pubkey_t *);
|
||||
int __ops_rsa_public_encrypt(uint8_t *, const uint8_t *, size_t,
|
||||
const __ops_rsa_pubkey_t *);
|
||||
int pgp_rsa_public_decrypt(uint8_t *, const uint8_t *, size_t,
|
||||
const pgp_rsa_pubkey_t *);
|
||||
int pgp_rsa_public_encrypt(uint8_t *, const uint8_t *, size_t,
|
||||
const pgp_rsa_pubkey_t *);
|
||||
|
||||
int __ops_rsa_private_encrypt(uint8_t *, const uint8_t *, size_t,
|
||||
const __ops_rsa_seckey_t *, const __ops_rsa_pubkey_t *);
|
||||
int __ops_rsa_private_decrypt(uint8_t *, const uint8_t *, size_t,
|
||||
const __ops_rsa_seckey_t *, const __ops_rsa_pubkey_t *);
|
||||
int pgp_rsa_private_encrypt(uint8_t *, const uint8_t *, size_t,
|
||||
const pgp_rsa_seckey_t *, const pgp_rsa_pubkey_t *);
|
||||
int pgp_rsa_private_decrypt(uint8_t *, const uint8_t *, size_t,
|
||||
const pgp_rsa_seckey_t *, const pgp_rsa_pubkey_t *);
|
||||
|
||||
int __ops_elgamal_public_encrypt(uint8_t *, uint8_t *, const uint8_t *, size_t,
|
||||
const __ops_elgamal_pubkey_t *);
|
||||
int __ops_elgamal_private_decrypt(uint8_t *, const uint8_t *, const uint8_t *, size_t,
|
||||
const __ops_elgamal_seckey_t *, const __ops_elgamal_pubkey_t *);
|
||||
int pgp_elgamal_public_encrypt(uint8_t *, uint8_t *, const uint8_t *, size_t,
|
||||
const pgp_elgamal_pubkey_t *);
|
||||
int pgp_elgamal_private_decrypt(uint8_t *, const uint8_t *, const uint8_t *, size_t,
|
||||
const pgp_elgamal_seckey_t *, const pgp_elgamal_pubkey_t *);
|
||||
|
||||
__ops_symm_alg_t __ops_str_to_cipher(const char *);
|
||||
unsigned __ops_block_size(__ops_symm_alg_t);
|
||||
unsigned __ops_key_size(__ops_symm_alg_t);
|
||||
pgp_symm_alg_t pgp_str_to_cipher(const char *);
|
||||
unsigned pgp_block_size(pgp_symm_alg_t);
|
||||
unsigned pgp_key_size(pgp_symm_alg_t);
|
||||
|
||||
int __ops_decrypt_data(__ops_content_enum, __ops_region_t *,
|
||||
__ops_stream_t *);
|
||||
int pgp_decrypt_data(pgp_content_enum, pgp_region_t *,
|
||||
pgp_stream_t *);
|
||||
|
||||
int __ops_crypt_any(__ops_crypt_t *, __ops_symm_alg_t);
|
||||
void __ops_decrypt_init(__ops_crypt_t *);
|
||||
void __ops_encrypt_init(__ops_crypt_t *);
|
||||
size_t __ops_decrypt_se(__ops_crypt_t *, void *, const void *, size_t);
|
||||
size_t __ops_encrypt_se(__ops_crypt_t *, void *, const void *, size_t);
|
||||
size_t __ops_decrypt_se_ip(__ops_crypt_t *, void *, const void *, size_t);
|
||||
size_t __ops_encrypt_se_ip(__ops_crypt_t *, void *, const void *, size_t);
|
||||
unsigned __ops_is_sa_supported(__ops_symm_alg_t);
|
||||
int pgp_crypt_any(pgp_crypt_t *, pgp_symm_alg_t);
|
||||
void pgp_decrypt_init(pgp_crypt_t *);
|
||||
void pgp_encrypt_init(pgp_crypt_t *);
|
||||
size_t pgp_decrypt_se(pgp_crypt_t *, void *, const void *, size_t);
|
||||
size_t pgp_encrypt_se(pgp_crypt_t *, void *, const void *, size_t);
|
||||
size_t pgp_decrypt_se_ip(pgp_crypt_t *, void *, const void *, size_t);
|
||||
size_t pgp_encrypt_se_ip(pgp_crypt_t *, void *, const void *, size_t);
|
||||
unsigned pgp_is_sa_supported(pgp_symm_alg_t);
|
||||
|
||||
void __ops_reader_push_decrypt(__ops_stream_t *, __ops_crypt_t *,
|
||||
__ops_region_t *);
|
||||
void __ops_reader_pop_decrypt(__ops_stream_t *);
|
||||
void pgp_reader_push_decrypt(pgp_stream_t *, pgp_crypt_t *,
|
||||
pgp_region_t *);
|
||||
void pgp_reader_pop_decrypt(pgp_stream_t *);
|
||||
|
||||
/* Hash everything that's read */
|
||||
void __ops_reader_push_hash(__ops_stream_t *, __ops_hash_t *);
|
||||
void __ops_reader_pop_hash(__ops_stream_t *);
|
||||
void pgp_reader_push_hash(pgp_stream_t *, pgp_hash_t *);
|
||||
void pgp_reader_pop_hash(pgp_stream_t *);
|
||||
|
||||
int __ops_decrypt_decode_mpi(uint8_t *, unsigned, const BIGNUM *,
|
||||
const BIGNUM *, const __ops_seckey_t *);
|
||||
int pgp_decrypt_decode_mpi(uint8_t *, unsigned, const BIGNUM *,
|
||||
const BIGNUM *, const pgp_seckey_t *);
|
||||
|
||||
unsigned __ops_rsa_encrypt_mpi(const uint8_t *, const size_t,
|
||||
const __ops_pubkey_t *,
|
||||
__ops_pk_sesskey_params_t *);
|
||||
unsigned __ops_elgamal_encrypt_mpi(const uint8_t *, const size_t,
|
||||
const __ops_pubkey_t *,
|
||||
__ops_pk_sesskey_params_t *);
|
||||
unsigned pgp_rsa_encrypt_mpi(const uint8_t *, const size_t,
|
||||
const pgp_pubkey_t *,
|
||||
pgp_pk_sesskey_params_t *);
|
||||
unsigned pgp_elgamal_encrypt_mpi(const uint8_t *, const size_t,
|
||||
const pgp_pubkey_t *,
|
||||
pgp_pk_sesskey_params_t *);
|
||||
|
||||
/* Encrypt everything that's written */
|
||||
struct __ops_key_data;
|
||||
void __ops_writer_push_encrypt(__ops_output_t *,
|
||||
const struct __ops_key_data *);
|
||||
struct pgp_key_data;
|
||||
void pgp_writer_push_encrypt(pgp_output_t *,
|
||||
const struct pgp_key_data *);
|
||||
|
||||
unsigned __ops_encrypt_file(__ops_io_t *, const char *, const char *,
|
||||
const __ops_key_t *,
|
||||
unsigned pgp_encrypt_file(pgp_io_t *, const char *, const char *,
|
||||
const pgp_key_t *,
|
||||
const unsigned, const unsigned, const char *);
|
||||
unsigned __ops_decrypt_file(__ops_io_t *,
|
||||
unsigned pgp_decrypt_file(pgp_io_t *,
|
||||
const char *,
|
||||
const char *,
|
||||
__ops_keyring_t *,
|
||||
__ops_keyring_t *,
|
||||
pgp_keyring_t *,
|
||||
pgp_keyring_t *,
|
||||
const unsigned,
|
||||
const unsigned,
|
||||
const unsigned,
|
||||
void *,
|
||||
__ops_cbfunc_t *);
|
||||
pgp_cbfunc_t *);
|
||||
|
||||
__ops_memory_t *
|
||||
__ops_encrypt_buf(__ops_io_t *, const void *, const size_t,
|
||||
const __ops_key_t *,
|
||||
pgp_memory_t *
|
||||
pgp_encrypt_buf(pgp_io_t *, const void *, const size_t,
|
||||
const pgp_key_t *,
|
||||
const unsigned, const char *);
|
||||
__ops_memory_t *
|
||||
__ops_decrypt_buf(__ops_io_t *,
|
||||
pgp_memory_t *
|
||||
pgp_decrypt_buf(pgp_io_t *,
|
||||
const void *,
|
||||
const size_t,
|
||||
__ops_keyring_t *,
|
||||
__ops_keyring_t *,
|
||||
pgp_keyring_t *,
|
||||
pgp_keyring_t *,
|
||||
const unsigned,
|
||||
const unsigned,
|
||||
void *,
|
||||
__ops_cbfunc_t *);
|
||||
pgp_cbfunc_t *);
|
||||
|
||||
/* Keys */
|
||||
__ops_key_t *__ops_rsa_new_selfsign_key(const int,
|
||||
pgp_key_t *pgp_rsa_new_selfsign_key(const int,
|
||||
const unsigned long, uint8_t *, const char *,
|
||||
const char *);
|
||||
|
||||
int __ops_dsa_size(const __ops_dsa_pubkey_t *);
|
||||
DSA_SIG *__ops_dsa_sign(uint8_t *, unsigned,
|
||||
const __ops_dsa_seckey_t *,
|
||||
const __ops_dsa_pubkey_t *);
|
||||
int pgp_dsa_size(const pgp_dsa_pubkey_t *);
|
||||
DSA_SIG *pgp_dsa_sign(uint8_t *, unsigned,
|
||||
const pgp_dsa_seckey_t *,
|
||||
const pgp_dsa_pubkey_t *);
|
||||
|
||||
int openssl_read_pem_seckey(const char *, __ops_key_t *, const char *, int);
|
||||
int openssl_read_pem_seckey(const char *, pgp_key_t *, const char *, int);
|
||||
|
||||
/** __ops_reader_t */
|
||||
struct __ops_reader_t {
|
||||
__ops_reader_func_t *reader; /* reader func to get parse data */
|
||||
__ops_reader_destroyer_t *destroyer;
|
||||
/** pgp_reader_t */
|
||||
struct pgp_reader_t {
|
||||
pgp_reader_func_t *reader; /* reader func to get parse data */
|
||||
pgp_reader_destroyer_t *destroyer;
|
||||
void *arg; /* args to pass to reader function */
|
||||
unsigned accumulate:1; /* set to gather packet data */
|
||||
uint8_t *accumulated; /* the accumulated data */
|
||||
unsigned asize; /* size of the buffer */
|
||||
unsigned alength;/* used buffer */
|
||||
unsigned position; /* reader-specific offset */
|
||||
__ops_reader_t *next;
|
||||
__ops_stream_t *parent;/* parent parse_info structure */
|
||||
pgp_reader_t *next;
|
||||
pgp_stream_t *parent;/* parent parse_info structure */
|
||||
};
|
||||
|
||||
|
||||
/** __ops_cryptinfo_t
|
||||
/** pgp_cryptinfo_t
|
||||
Encrypt/decrypt settings
|
||||
*/
|
||||
struct __ops_cryptinfo_t {
|
||||
struct pgp_cryptinfo_t {
|
||||
char *passphrase;
|
||||
__ops_keyring_t *secring;
|
||||
const __ops_key_t *keydata;
|
||||
__ops_cbfunc_t *getpassphrase;
|
||||
__ops_keyring_t *pubring;
|
||||
pgp_keyring_t *secring;
|
||||
const pgp_key_t *keydata;
|
||||
pgp_cbfunc_t *getpassphrase;
|
||||
pgp_keyring_t *pubring;
|
||||
};
|
||||
|
||||
/** __ops_cbdata_t */
|
||||
struct __ops_cbdata_t {
|
||||
__ops_cbfunc_t *cbfunc; /* callback function */
|
||||
/** pgp_cbdata_t */
|
||||
struct pgp_cbdata_t {
|
||||
pgp_cbfunc_t *cbfunc; /* callback function */
|
||||
void *arg; /* args to pass to callback func */
|
||||
__ops_error_t **errors; /* address of error stack */
|
||||
__ops_cbdata_t *next;
|
||||
__ops_output_t *output;/* used if writing out parsed info */
|
||||
__ops_io_t *io; /* error/output messages */
|
||||
pgp_error_t **errors; /* address of error stack */
|
||||
pgp_cbdata_t *next;
|
||||
pgp_output_t *output;/* used if writing out parsed info */
|
||||
pgp_io_t *io; /* error/output messages */
|
||||
void *passfp; /* fp for passphrase input */
|
||||
__ops_cryptinfo_t cryptinfo; /* used when decrypting */
|
||||
__ops_printstate_t printstate; /* used to keep state when printing */
|
||||
__ops_seckey_t *sshseckey; /* secret key for ssh */
|
||||
pgp_cryptinfo_t cryptinfo; /* used when decrypting */
|
||||
pgp_printstate_t printstate; /* used to keep state when printing */
|
||||
pgp_seckey_t *sshseckey; /* secret key for ssh */
|
||||
};
|
||||
|
||||
/** __ops_hashtype_t */
|
||||
/** pgp_hashtype_t */
|
||||
typedef struct {
|
||||
__ops_hash_t hash; /* hashes we should hash data with */
|
||||
uint8_t keyid[OPS_KEY_ID_SIZE];
|
||||
} __ops_hashtype_t;
|
||||
pgp_hash_t hash; /* hashes we should hash data with */
|
||||
uint8_t keyid[PGP_KEY_ID_SIZE];
|
||||
} pgp_hashtype_t;
|
||||
|
||||
#define NTAGS 0x100 /* == 256 */
|
||||
|
||||
@ -284,19 +284,19 @@ typedef struct {
|
||||
* It has a linked list of errors.
|
||||
*/
|
||||
|
||||
struct __ops_stream_t {
|
||||
struct pgp_stream_t {
|
||||
uint8_t ss_raw[NTAGS / 8];
|
||||
/* 1 bit / sig-subpkt type; set to get raw data */
|
||||
uint8_t ss_parsed[NTAGS / 8];
|
||||
/* 1 bit / sig-subpkt type; set to get parsed data */
|
||||
__ops_reader_t readinfo;
|
||||
__ops_cbdata_t cbinfo;
|
||||
__ops_error_t *errors;
|
||||
pgp_reader_t readinfo;
|
||||
pgp_cbdata_t cbinfo;
|
||||
pgp_error_t *errors;
|
||||
void *io; /* io streams */
|
||||
__ops_crypt_t decrypt;
|
||||
__ops_cryptinfo_t cryptinfo;
|
||||
pgp_crypt_t decrypt;
|
||||
pgp_cryptinfo_t cryptinfo;
|
||||
size_t hashc;
|
||||
__ops_hashtype_t *hashes;
|
||||
pgp_hashtype_t *hashes;
|
||||
unsigned reading_v3_secret:1;
|
||||
unsigned reading_mpi_len:1;
|
||||
unsigned exact_read:1;
|
||||
|
138
crypto/external/bsd/netpgp/dist/src/lib/errors.h
vendored
138
crypto/external/bsd/netpgp/dist/src/lib/errors.h
vendored
@ -58,112 +58,112 @@
|
||||
/** error codes */
|
||||
/* Remember to add names to map in errors.c */
|
||||
typedef enum {
|
||||
OPS_E_OK = 0x0000, /* no error */
|
||||
OPS_E_FAIL = 0x0001, /* general error */
|
||||
OPS_E_SYSTEM_ERROR = 0x0002, /* system error, look at errno for
|
||||
PGP_E_OK = 0x0000, /* no error */
|
||||
PGP_E_FAIL = 0x0001, /* general error */
|
||||
PGP_E_SYSTEM_ERROR = 0x0002, /* system error, look at errno for
|
||||
* details */
|
||||
OPS_E_UNIMPLEMENTED = 0x0003, /* feature not yet implemented */
|
||||
PGP_E_UNIMPLEMENTED = 0x0003, /* feature not yet implemented */
|
||||
|
||||
/* reader errors */
|
||||
OPS_E_R = 0x1000, /* general reader error */
|
||||
OPS_E_R_READ_FAILED = OPS_E_R + 1,
|
||||
OPS_E_R_EARLY_EOF = OPS_E_R + 2,
|
||||
OPS_E_R_BAD_FORMAT = OPS_E_R + 3, /* For example, malformed
|
||||
PGP_E_R = 0x1000, /* general reader error */
|
||||
PGP_E_R_READ_FAILED = PGP_E_R + 1,
|
||||
PGP_E_R_EARLY_EOF = PGP_E_R + 2,
|
||||
PGP_E_R_BAD_FORMAT = PGP_E_R + 3, /* For example, malformed
|
||||
* armour */
|
||||
OPS_E_R_UNSUPPORTED = OPS_E_R + 4,
|
||||
OPS_E_R_UNCONSUMED_DATA = OPS_E_R + 5,
|
||||
PGP_E_R_UNSUPPORTED = PGP_E_R + 4,
|
||||
PGP_E_R_UNCONSUMED_DATA = PGP_E_R + 5,
|
||||
|
||||
/* writer errors */
|
||||
OPS_E_W = 0x2000, /* general writer error */
|
||||
OPS_E_W_WRITE_FAILED = OPS_E_W + 1,
|
||||
OPS_E_W_WRITE_TOO_SHORT = OPS_E_W + 2,
|
||||
PGP_E_W = 0x2000, /* general writer error */
|
||||
PGP_E_W_WRITE_FAILED = PGP_E_W + 1,
|
||||
PGP_E_W_WRITE_TOO_SHORT = PGP_E_W + 2,
|
||||
|
||||
/* parser errors */
|
||||
OPS_E_P = 0x3000, /* general parser error */
|
||||
OPS_E_P_NOT_ENOUGH_DATA = OPS_E_P + 1,
|
||||
OPS_E_P_UNKNOWN_TAG = OPS_E_P + 2,
|
||||
OPS_E_P_PACKET_CONSUMED = OPS_E_P + 3,
|
||||
OPS_E_P_MPI_FORMAT_ERROR = OPS_E_P + 4,
|
||||
OPS_E_P_PACKET_NOT_CONSUMED = OPS_E_P + 5,
|
||||
OPS_E_P_DECOMPRESSION_ERROR = OPS_E_P + 6,
|
||||
OPS_E_P_NO_USERID = OPS_E_P + 7,
|
||||
PGP_E_P = 0x3000, /* general parser error */
|
||||
PGP_E_P_NOT_ENOUGH_DATA = PGP_E_P + 1,
|
||||
PGP_E_P_UNKNOWN_TAG = PGP_E_P + 2,
|
||||
PGP_E_P_PACKET_CONSUMED = PGP_E_P + 3,
|
||||
PGP_E_P_MPI_FORMAT_ERROR = PGP_E_P + 4,
|
||||
PGP_E_P_PACKET_NOT_CONSUMED = PGP_E_P + 5,
|
||||
PGP_E_P_DECOMPRESSION_ERROR = PGP_E_P + 6,
|
||||
PGP_E_P_NO_USERID = PGP_E_P + 7,
|
||||
|
||||
/* creator errors */
|
||||
OPS_E_C = 0x4000, /* general creator error */
|
||||
PGP_E_C = 0x4000, /* general creator error */
|
||||
|
||||
/* validation errors */
|
||||
OPS_E_V = 0x5000, /* general validation error */
|
||||
OPS_E_V_BAD_SIGNATURE = OPS_E_V + 1,
|
||||
OPS_E_V_NO_SIGNATURE = OPS_E_V + 2,
|
||||
OPS_E_V_UNKNOWN_SIGNER = OPS_E_V + 3,
|
||||
OPS_E_V_BAD_HASH = OPS_E_V + 4,
|
||||
PGP_E_V = 0x5000, /* general validation error */
|
||||
PGP_E_V_BAD_SIGNATURE = PGP_E_V + 1,
|
||||
PGP_E_V_NO_SIGNATURE = PGP_E_V + 2,
|
||||
PGP_E_V_UNKNOWN_SIGNER = PGP_E_V + 3,
|
||||
PGP_E_V_BAD_HASH = PGP_E_V + 4,
|
||||
|
||||
/* Algorithm support errors */
|
||||
OPS_E_ALG = 0x6000, /* general algorithm error */
|
||||
OPS_E_ALG_UNSUPPORTED_SYMMETRIC_ALG = OPS_E_ALG + 1,
|
||||
OPS_E_ALG_UNSUPPORTED_PUBLIC_KEY_ALG = OPS_E_ALG + 2,
|
||||
OPS_E_ALG_UNSUPPORTED_SIGNATURE_ALG = OPS_E_ALG + 3,
|
||||
OPS_E_ALG_UNSUPPORTED_HASH_ALG = OPS_E_ALG + 4,
|
||||
OPS_E_ALG_UNSUPPORTED_COMPRESS_ALG = OPS_E_ALG + 5,
|
||||
PGP_E_ALG = 0x6000, /* general algorithm error */
|
||||
PGP_E_ALG_UNSUPPORTED_SYMMETRIC_ALG = PGP_E_ALG + 1,
|
||||
PGP_E_ALG_UNSUPPORTED_PUBLIC_KEY_ALG = PGP_E_ALG + 2,
|
||||
PGP_E_ALG_UNSUPPORTED_SIGNATURE_ALG = PGP_E_ALG + 3,
|
||||
PGP_E_ALG_UNSUPPORTED_HASH_ALG = PGP_E_ALG + 4,
|
||||
PGP_E_ALG_UNSUPPORTED_COMPRESS_ALG = PGP_E_ALG + 5,
|
||||
|
||||
/* Protocol errors */
|
||||
OPS_E_PROTO = 0x7000, /* general protocol error */
|
||||
OPS_E_PROTO_BAD_SYMMETRIC_DECRYPT = OPS_E_PROTO + 2,
|
||||
OPS_E_PROTO_UNKNOWN_SS = OPS_E_PROTO + 3,
|
||||
OPS_E_PROTO_CRITICAL_SS_IGNORED = OPS_E_PROTO + 4,
|
||||
OPS_E_PROTO_BAD_PUBLIC_KEY_VRSN = OPS_E_PROTO + 5,
|
||||
OPS_E_PROTO_BAD_SIGNATURE_VRSN = OPS_E_PROTO + 6,
|
||||
OPS_E_PROTO_BAD_ONE_PASS_SIG_VRSN = OPS_E_PROTO + 7,
|
||||
OPS_E_PROTO_BAD_PKSK_VRSN = OPS_E_PROTO + 8,
|
||||
OPS_E_PROTO_DECRYPTED_MSG_WRONG_LEN = OPS_E_PROTO + 9,
|
||||
OPS_E_PROTO_BAD_SK_CHECKSUM = OPS_E_PROTO + 10
|
||||
} __ops_errcode_t;
|
||||
PGP_E_PROTO = 0x7000, /* general protocol error */
|
||||
PGP_E_PROTO_BAD_SYMMETRIC_DECRYPT = PGP_E_PROTO + 2,
|
||||
PGP_E_PROTO_UNKNOWN_SS = PGP_E_PROTO + 3,
|
||||
PGP_E_PROTO_CRITICAL_SS_IGNORED = PGP_E_PROTO + 4,
|
||||
PGP_E_PROTO_BAD_PUBLIC_KEY_VRSN = PGP_E_PROTO + 5,
|
||||
PGP_E_PROTO_BAD_SIGNATURE_VRSN = PGP_E_PROTO + 6,
|
||||
PGP_E_PROTO_BAD_ONE_PASS_SIG_VRSN = PGP_E_PROTO + 7,
|
||||
PGP_E_PROTO_BAD_PKSK_VRSN = PGP_E_PROTO + 8,
|
||||
PGP_E_PROTO_DECRYPTED_MSG_WRONG_LEN = PGP_E_PROTO + 9,
|
||||
PGP_E_PROTO_BAD_SK_CHECKSUM = PGP_E_PROTO + 10
|
||||
} pgp_errcode_t;
|
||||
|
||||
/** one entry in a linked list of errors */
|
||||
typedef struct __ops_error {
|
||||
__ops_errcode_t errcode;
|
||||
typedef struct pgp_error {
|
||||
pgp_errcode_t errcode;
|
||||
int sys_errno; /* irrelevent unless errcode ==
|
||||
* OPS_E_SYSTEM_ERROR */
|
||||
* PGP_E_SYSTEM_ERROR */
|
||||
char *comment;
|
||||
const char *file;
|
||||
int line;
|
||||
struct __ops_error *next;
|
||||
} __ops_error_t;
|
||||
struct pgp_error *next;
|
||||
} pgp_error_t;
|
||||
|
||||
const char *__ops_errcode(const __ops_errcode_t);
|
||||
const char *pgp_errcode(const pgp_errcode_t);
|
||||
|
||||
void
|
||||
__ops_push_error(__ops_error_t **, __ops_errcode_t,
|
||||
pgp_push_error(pgp_error_t **, pgp_errcode_t,
|
||||
int,
|
||||
const char *, int, const char *,...);
|
||||
void __ops_print_error(__ops_error_t *);
|
||||
void __ops_print_errors(__ops_error_t *);
|
||||
void __ops_free_errors(__ops_error_t *);
|
||||
int __ops_has_error(__ops_error_t *, __ops_errcode_t);
|
||||
void pgp_print_error(pgp_error_t *);
|
||||
void pgp_print_errors(pgp_error_t *);
|
||||
void pgp_free_errors(pgp_error_t *);
|
||||
int pgp_has_error(pgp_error_t *, pgp_errcode_t);
|
||||
|
||||
#define OPS_SYSTEM_ERROR_1(err,code,sys,fmt,arg) do { \
|
||||
__ops_push_error(err,OPS_E_SYSTEM_ERROR,errno,__FILE__,__LINE__,sys);\
|
||||
__ops_push_error(err,code,0,__FILE__,__LINE__,fmt,arg); \
|
||||
#define PGP_SYSTEM_ERROR_1(err,code,sys,fmt,arg) do { \
|
||||
pgp_push_error(err,PGP_E_SYSTEM_ERROR,errno,__FILE__,__LINE__,sys);\
|
||||
pgp_push_error(err,code,0,__FILE__,__LINE__,fmt,arg); \
|
||||
} while(/*CONSTCOND*/0)
|
||||
|
||||
#define OPS_MEMORY_ERROR(err) { \
|
||||
#define PGP_MEMORY_ERROR(err) { \
|
||||
fprintf(stderr, "Memory error\n"); \
|
||||
} /* \todo placeholder for better error
|
||||
* handling */
|
||||
#define OPS_ERROR(err,code,fmt) do { \
|
||||
__ops_push_error(err,code,0,__FILE__,__LINE__,fmt); \
|
||||
#define PGP_ERROR(err,code,fmt) do { \
|
||||
pgp_push_error(err,code,0,__FILE__,__LINE__,fmt); \
|
||||
} while(/*CONSTCOND*/0)
|
||||
#define OPS_ERROR_1(err,code,fmt,arg) do { \
|
||||
__ops_push_error(err,code,0,__FILE__,__LINE__,fmt,arg); \
|
||||
#define PGP_ERROR_1(err,code,fmt,arg) do { \
|
||||
pgp_push_error(err,code,0,__FILE__,__LINE__,fmt,arg); \
|
||||
} while(/*CONSTCOND*/0)
|
||||
#define OPS_ERROR_2(err,code,fmt,arg,arg2) do { \
|
||||
__ops_push_error(err,code,0,__FILE__,__LINE__,fmt,arg,arg2); \
|
||||
#define PGP_ERROR_2(err,code,fmt,arg,arg2) do { \
|
||||
pgp_push_error(err,code,0,__FILE__,__LINE__,fmt,arg,arg2); \
|
||||
} while(/*CONSTCOND*/0)
|
||||
#define OPS_ERROR_3(err,code,fmt,arg,arg2,arg3) do { \
|
||||
__ops_push_error(err,code,0,__FILE__,__LINE__,fmt,arg,arg2,arg3); \
|
||||
#define PGP_ERROR_3(err,code,fmt,arg,arg2,arg3) do { \
|
||||
pgp_push_error(err,code,0,__FILE__,__LINE__,fmt,arg,arg2,arg3); \
|
||||
} while(/*CONSTCOND*/0)
|
||||
#define OPS_ERROR_4(err,code,fmt,arg,arg2,arg3,arg4) do { \
|
||||
__ops_push_error(err,code,0,__FILE__,__LINE__,fmt,arg,arg2,arg3,arg4); \
|
||||
#define PGP_ERROR_4(err,code,fmt,arg,arg2,arg3,arg4) do { \
|
||||
pgp_push_error(err,code,0,__FILE__,__LINE__,fmt,arg,arg2,arg3,arg4); \
|
||||
} while(/*CONSTCOND*/0)
|
||||
|
||||
#endif /* ERRORS_H_ */
|
||||
|
520
crypto/external/bsd/netpgp/dist/src/lib/keyring.c
vendored
520
crypto/external/bsd/netpgp/dist/src/lib/keyring.c
vendored
File diff suppressed because it is too large
Load Diff
120
crypto/external/bsd/netpgp/dist/src/lib/keyring.h
vendored
120
crypto/external/bsd/netpgp/dist/src/lib/keyring.h
vendored
@ -62,91 +62,91 @@ enum {
|
||||
MAX_PASSPHRASE_LENGTH = 256
|
||||
};
|
||||
|
||||
typedef struct __ops_key_t __ops_key_t;
|
||||
typedef struct pgp_key_t pgp_key_t;
|
||||
|
||||
/** \struct __ops_keyring_t
|
||||
/** \struct pgp_keyring_t
|
||||
* A keyring
|
||||
*/
|
||||
typedef struct __ops_keyring_t {
|
||||
DYNARRAY(__ops_key_t, key);
|
||||
__ops_hash_alg_t hashtype;
|
||||
} __ops_keyring_t;
|
||||
typedef struct pgp_keyring_t {
|
||||
DYNARRAY(pgp_key_t, key);
|
||||
pgp_hash_alg_t hashtype;
|
||||
} pgp_keyring_t;
|
||||
|
||||
const __ops_key_t *__ops_getkeybyid(__ops_io_t *,
|
||||
const __ops_keyring_t *,
|
||||
const pgp_key_t *pgp_getkeybyid(pgp_io_t *,
|
||||
const pgp_keyring_t *,
|
||||
const uint8_t *,
|
||||
unsigned *,
|
||||
__ops_pubkey_t **);
|
||||
const __ops_key_t *__ops_getkeybyname(__ops_io_t *,
|
||||
const __ops_keyring_t *,
|
||||
pgp_pubkey_t **);
|
||||
const pgp_key_t *pgp_getkeybyname(pgp_io_t *,
|
||||
const pgp_keyring_t *,
|
||||
const char *);
|
||||
const __ops_key_t *__ops_getnextkeybyname(__ops_io_t *,
|
||||
const __ops_keyring_t *,
|
||||
const pgp_key_t *pgp_getnextkeybyname(pgp_io_t *,
|
||||
const pgp_keyring_t *,
|
||||
const char *,
|
||||
unsigned *);
|
||||
void __ops_keydata_free(__ops_key_t *);
|
||||
void __ops_keyring_free(__ops_keyring_t *);
|
||||
void __ops_dump_keyring(const __ops_keyring_t *);
|
||||
const __ops_pubkey_t *__ops_get_pubkey(const __ops_key_t *);
|
||||
unsigned __ops_is_key_secret(const __ops_key_t *);
|
||||
const __ops_seckey_t *__ops_get_seckey(const __ops_key_t *);
|
||||
__ops_seckey_t *__ops_get_writable_seckey(__ops_key_t *);
|
||||
__ops_seckey_t *__ops_decrypt_seckey(const __ops_key_t *, void *);
|
||||
void pgp_keydata_free(pgp_key_t *);
|
||||
void pgp_keyring_free(pgp_keyring_t *);
|
||||
void pgp_dump_keyring(const pgp_keyring_t *);
|
||||
const pgp_pubkey_t *pgp_get_pubkey(const pgp_key_t *);
|
||||
unsigned pgp_is_key_secret(const pgp_key_t *);
|
||||
const pgp_seckey_t *pgp_get_seckey(const pgp_key_t *);
|
||||
pgp_seckey_t *pgp_get_writable_seckey(pgp_key_t *);
|
||||
pgp_seckey_t *pgp_decrypt_seckey(const pgp_key_t *, void *);
|
||||
|
||||
unsigned __ops_keyring_fileread(__ops_keyring_t *, const unsigned,
|
||||
unsigned pgp_keyring_fileread(pgp_keyring_t *, const unsigned,
|
||||
const char *);
|
||||
|
||||
int __ops_keyring_list(__ops_io_t *, const __ops_keyring_t *, const int);
|
||||
int __ops_keyring_json(__ops_io_t *, const __ops_keyring_t *, mj_t *, const int);
|
||||
int pgp_keyring_list(pgp_io_t *, const pgp_keyring_t *, const int);
|
||||
int pgp_keyring_json(pgp_io_t *, const pgp_keyring_t *, mj_t *, const int);
|
||||
|
||||
void __ops_set_seckey(__ops_contents_t *, const __ops_key_t *);
|
||||
void __ops_forget(void *, unsigned);
|
||||
void pgp_set_seckey(pgp_contents_t *, const pgp_key_t *);
|
||||
void pgp_forget(void *, unsigned);
|
||||
|
||||
const uint8_t *__ops_get_key_id(const __ops_key_t *);
|
||||
unsigned __ops_get_userid_count(const __ops_key_t *);
|
||||
const uint8_t *__ops_get_userid(const __ops_key_t *, unsigned);
|
||||
unsigned __ops_is_key_supported(const __ops_key_t *);
|
||||
const uint8_t *pgp_get_key_id(const pgp_key_t *);
|
||||
unsigned pgp_get_userid_count(const pgp_key_t *);
|
||||
const uint8_t *pgp_get_userid(const pgp_key_t *, unsigned);
|
||||
unsigned pgp_is_key_supported(const pgp_key_t *);
|
||||
|
||||
uint8_t *__ops_add_userid(__ops_key_t *, const uint8_t *);
|
||||
__ops_subpacket_t *__ops_add_subpacket(__ops_key_t *,
|
||||
const __ops_subpacket_t *);
|
||||
uint8_t *pgp_add_userid(pgp_key_t *, const uint8_t *);
|
||||
pgp_subpacket_t *pgp_add_subpacket(pgp_key_t *,
|
||||
const pgp_subpacket_t *);
|
||||
|
||||
unsigned __ops_add_selfsigned_userid(__ops_key_t *, uint8_t *);
|
||||
unsigned pgp_add_selfsigned_userid(pgp_key_t *, uint8_t *);
|
||||
|
||||
__ops_key_t *__ops_keydata_new(void);
|
||||
void __ops_keydata_init(__ops_key_t *, const __ops_content_enum);
|
||||
pgp_key_t *pgp_keydata_new(void);
|
||||
void pgp_keydata_init(pgp_key_t *, const pgp_content_enum);
|
||||
|
||||
int __ops_parse_and_accumulate(__ops_keyring_t *, __ops_stream_t *);
|
||||
int pgp_parse_and_accumulate(pgp_keyring_t *, pgp_stream_t *);
|
||||
|
||||
int __ops_sprint_keydata(__ops_io_t *, const __ops_keyring_t *,
|
||||
const __ops_key_t *, char **, const char *,
|
||||
const __ops_pubkey_t *, const int);
|
||||
int __ops_sprint_mj(__ops_io_t *, const __ops_keyring_t *,
|
||||
const __ops_key_t *, mj_t *, const char *,
|
||||
const __ops_pubkey_t *, const int);
|
||||
int __ops_hkp_sprint_keydata(__ops_io_t *, const __ops_keyring_t *,
|
||||
const __ops_key_t *, char **,
|
||||
const __ops_pubkey_t *, const int);
|
||||
void __ops_print_keydata(__ops_io_t *, const __ops_keyring_t *, const __ops_key_t *,
|
||||
const char *, const __ops_pubkey_t *, const int);
|
||||
void __ops_print_sig(__ops_io_t *, const __ops_key_t *, const char *,
|
||||
const __ops_pubkey_t *);
|
||||
void __ops_print_pubkey(const __ops_pubkey_t *);
|
||||
int __ops_sprint_pubkey(const __ops_key_t *, char *, size_t);
|
||||
int pgp_sprint_keydata(pgp_io_t *, const pgp_keyring_t *,
|
||||
const pgp_key_t *, char **, const char *,
|
||||
const pgp_pubkey_t *, const int);
|
||||
int pgp_sprint_mj(pgp_io_t *, const pgp_keyring_t *,
|
||||
const pgp_key_t *, mj_t *, const char *,
|
||||
const pgp_pubkey_t *, const int);
|
||||
int pgp_hkp_sprint_keydata(pgp_io_t *, const pgp_keyring_t *,
|
||||
const pgp_key_t *, char **,
|
||||
const pgp_pubkey_t *, const int);
|
||||
void pgp_print_keydata(pgp_io_t *, const pgp_keyring_t *, const pgp_key_t *,
|
||||
const char *, const pgp_pubkey_t *, const int);
|
||||
void pgp_print_sig(pgp_io_t *, const pgp_key_t *, const char *,
|
||||
const pgp_pubkey_t *);
|
||||
void pgp_print_pubkey(const pgp_pubkey_t *);
|
||||
int pgp_sprint_pubkey(const pgp_key_t *, char *, size_t);
|
||||
|
||||
int __ops_list_packets(__ops_io_t *,
|
||||
int pgp_list_packets(pgp_io_t *,
|
||||
char *,
|
||||
unsigned,
|
||||
__ops_keyring_t *,
|
||||
__ops_keyring_t *,
|
||||
pgp_keyring_t *,
|
||||
pgp_keyring_t *,
|
||||
void *,
|
||||
__ops_cbfunc_t *);
|
||||
pgp_cbfunc_t *);
|
||||
|
||||
char *__ops_export_key(__ops_io_t *, const __ops_key_t *, uint8_t *);
|
||||
char *pgp_export_key(pgp_io_t *, const pgp_key_t *, uint8_t *);
|
||||
|
||||
int __ops_add_to_pubring(__ops_keyring_t *, const __ops_pubkey_t *, __ops_content_enum tag);
|
||||
int __ops_add_to_secring(__ops_keyring_t *, const __ops_seckey_t *);
|
||||
int pgp_add_to_pubring(pgp_keyring_t *, const pgp_pubkey_t *, pgp_content_enum tag);
|
||||
int pgp_add_to_secring(pgp_keyring_t *, const pgp_seckey_t *);
|
||||
|
||||
int __ops_append_keyring(__ops_keyring_t *, __ops_keyring_t *);
|
||||
int pgp_append_keyring(pgp_keyring_t *, pgp_keyring_t *);
|
||||
|
||||
#endif /* KEYRING_H_ */
|
||||
|
34
crypto/external/bsd/netpgp/dist/src/lib/memory.h
vendored
34
crypto/external/bsd/netpgp/dist/src/lib/memory.h
vendored
@ -56,32 +56,32 @@
|
||||
|
||||
#include "packet.h"
|
||||
|
||||
/** __ops_memory_t
|
||||
/** pgp_memory_t
|
||||
*/
|
||||
typedef struct __ops_memory_t {
|
||||
typedef struct pgp_memory_t {
|
||||
uint8_t *buf;
|
||||
size_t length;
|
||||
size_t allocated;
|
||||
unsigned mmapped;
|
||||
} __ops_memory_t;
|
||||
} pgp_memory_t;
|
||||
|
||||
|
||||
__ops_memory_t *__ops_memory_new(void);
|
||||
void __ops_memory_free(__ops_memory_t *);
|
||||
void __ops_memory_init(__ops_memory_t *, size_t);
|
||||
void __ops_memory_pad(__ops_memory_t *, size_t);
|
||||
void __ops_memory_add(__ops_memory_t *, const uint8_t *, size_t);
|
||||
void __ops_memory_place_int(__ops_memory_t *, unsigned, unsigned, size_t);
|
||||
void __ops_memory_make_packet(__ops_memory_t *, __ops_content_enum);
|
||||
void __ops_memory_clear(__ops_memory_t *);
|
||||
void __ops_memory_release(__ops_memory_t *);
|
||||
pgp_memory_t *pgp_memory_new(void);
|
||||
void pgp_memory_free(pgp_memory_t *);
|
||||
void pgp_memory_init(pgp_memory_t *, size_t);
|
||||
void pgp_memory_pad(pgp_memory_t *, size_t);
|
||||
void pgp_memory_add(pgp_memory_t *, const uint8_t *, size_t);
|
||||
void pgp_memory_place_int(pgp_memory_t *, unsigned, unsigned, size_t);
|
||||
void pgp_memory_make_packet(pgp_memory_t *, pgp_content_enum);
|
||||
void pgp_memory_clear(pgp_memory_t *);
|
||||
void pgp_memory_release(pgp_memory_t *);
|
||||
|
||||
void __ops_writer_set_memory(__ops_output_t *, __ops_memory_t *);
|
||||
void pgp_writer_set_memory(pgp_output_t *, pgp_memory_t *);
|
||||
|
||||
size_t __ops_mem_len(const __ops_memory_t *);
|
||||
void *__ops_mem_data(__ops_memory_t *);
|
||||
int __ops_mem_readfile(__ops_memory_t *, const char *);
|
||||
size_t pgp_mem_len(const pgp_memory_t *);
|
||||
void *pgp_mem_data(pgp_memory_t *);
|
||||
int pgp_mem_readfile(pgp_memory_t *, const char *);
|
||||
|
||||
void __ops_random(void *, size_t);
|
||||
void pgp_random(void *, size_t);
|
||||
|
||||
#endif /* MEMORY_H_ */
|
||||
|
500
crypto/external/bsd/netpgp/dist/src/lib/misc.c
vendored
500
crypto/external/bsd/netpgp/dist/src/lib/misc.c
vendored
File diff suppressed because it is too large
Load Diff
312
crypto/external/bsd/netpgp/dist/src/lib/netpgp.c
vendored
312
crypto/external/bsd/netpgp/dist/src/lib/netpgp.c
vendored
@ -34,7 +34,7 @@
|
||||
|
||||
#if defined(__NetBSD__)
|
||||
__COPYRIGHT("@(#) Copyright (c) 2009 The NetBSD Foundation, Inc. All rights reserved.");
|
||||
__RCSID("$NetBSD: netpgp.c,v 1.80 2010/11/04 15:38:45 agc Exp $");
|
||||
__RCSID("$NetBSD: netpgp.c,v 1.81 2010/11/07 08:39:59 agc Exp $");
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
@ -93,7 +93,7 @@ conffile(netpgp_t *netpgp, char *homedir, char *userid, size_t length)
|
||||
char buf[BUFSIZ];
|
||||
FILE *fp;
|
||||
|
||||
__OPS_USED(netpgp);
|
||||
__PGP_USED(netpgp);
|
||||
(void) snprintf(buf, sizeof(buf), "%s/gpg.conf", homedir);
|
||||
if ((fp = fopen(buf, "r")) == NULL) {
|
||||
return 0;
|
||||
@ -136,13 +136,13 @@ userid_to_id(const uint8_t *userid, char *id)
|
||||
|
||||
/* print out the successful signature information */
|
||||
static void
|
||||
resultp(__ops_io_t *io,
|
||||
resultp(pgp_io_t *io,
|
||||
const char *f,
|
||||
__ops_validation_t *res,
|
||||
__ops_keyring_t *ring)
|
||||
pgp_validation_t *res,
|
||||
pgp_keyring_t *ring)
|
||||
{
|
||||
const __ops_key_t *key;
|
||||
__ops_pubkey_t *sigkey;
|
||||
const pgp_key_t *key;
|
||||
pgp_pubkey_t *sigkey;
|
||||
unsigned from;
|
||||
unsigned i;
|
||||
time_t t;
|
||||
@ -159,10 +159,10 @@ resultp(__ops_io_t *io,
|
||||
}
|
||||
(void) fprintf(io->res,
|
||||
"using %s key %s\n",
|
||||
__ops_show_pka(res->valid_sigs[i].key_alg),
|
||||
pgp_show_pka(res->valid_sigs[i].key_alg),
|
||||
userid_to_id(res->valid_sigs[i].signer_id, id));
|
||||
from = 0;
|
||||
key = __ops_getkeybyid(io, ring,
|
||||
key = pgp_getkeybyid(io, ring,
|
||||
(const uint8_t *) res->valid_sigs[i].signer_id,
|
||||
&from, &sigkey);
|
||||
if (sigkey == &key->enckey) {
|
||||
@ -170,7 +170,7 @@ resultp(__ops_io_t *io,
|
||||
"WARNING: signature for %s made with encryption key\n",
|
||||
(f) ? f : "<stdin>");
|
||||
}
|
||||
__ops_print_keydata(io, ring, key, "signature ", &key->key.pubkey, 0);
|
||||
pgp_print_keydata(io, ring, key, "signature ", &key->key.pubkey, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@ -226,7 +226,7 @@ findvar(netpgp_t *netpgp, const char *name)
|
||||
static void *
|
||||
readkeyring(netpgp_t *netpgp, const char *name)
|
||||
{
|
||||
__ops_keyring_t *keyring;
|
||||
pgp_keyring_t *keyring;
|
||||
const unsigned noarmor = 0;
|
||||
char f[MAXPATHLEN];
|
||||
char *filename;
|
||||
@ -241,7 +241,7 @@ readkeyring(netpgp_t *netpgp, const char *name)
|
||||
(void) fprintf(stderr, "readkeyring: bad alloc\n");
|
||||
return NULL;
|
||||
}
|
||||
if (!__ops_keyring_fileread(keyring, noarmor, filename)) {
|
||||
if (!pgp_keyring_fileread(keyring, noarmor, filename)) {
|
||||
free(keyring);
|
||||
(void) fprintf(stderr, "Can't read %s %s\n", name, filename);
|
||||
return NULL;
|
||||
@ -254,8 +254,8 @@ readkeyring(netpgp_t *netpgp, const char *name)
|
||||
static int
|
||||
readsshkeys(netpgp_t *netpgp, char *homedir, const char *needseckey)
|
||||
{
|
||||
__ops_keyring_t *pubring;
|
||||
__ops_keyring_t *secring;
|
||||
pgp_keyring_t *pubring;
|
||||
pgp_keyring_t *secring;
|
||||
struct stat st;
|
||||
unsigned hashtype;
|
||||
char *hash;
|
||||
@ -281,18 +281,18 @@ readsshkeys(netpgp_t *netpgp, char *homedir, const char *needseckey)
|
||||
return 0;
|
||||
}
|
||||
/* openssh2 keys use md5 by default */
|
||||
hashtype = OPS_HASH_MD5;
|
||||
hashtype = PGP_HASH_MD5;
|
||||
if ((hash = netpgp_getvar(netpgp, "hash")) != NULL) {
|
||||
/* openssh 2 hasn't really caught up to anything else yet */
|
||||
if (netpgp_strcasecmp(hash, "md5") == 0) {
|
||||
hashtype = OPS_HASH_MD5;
|
||||
hashtype = PGP_HASH_MD5;
|
||||
} else if (netpgp_strcasecmp(hash, "sha1") == 0) {
|
||||
hashtype = OPS_HASH_SHA1;
|
||||
hashtype = PGP_HASH_SHA1;
|
||||
} else if (netpgp_strcasecmp(hash, "sha256") == 0) {
|
||||
hashtype = OPS_HASH_SHA256;
|
||||
hashtype = PGP_HASH_SHA256;
|
||||
}
|
||||
}
|
||||
if (!__ops_ssh2_readkeys(netpgp->io, pubring, NULL, filename, NULL, hashtype)) {
|
||||
if (!pgp_ssh2_readkeys(netpgp->io, pubring, NULL, filename, NULL, hashtype)) {
|
||||
free(pubring);
|
||||
(void) fprintf(stderr, "readsshkeys: can't read %s\n",
|
||||
filename);
|
||||
@ -301,7 +301,7 @@ readsshkeys(netpgp_t *netpgp, char *homedir, const char *needseckey)
|
||||
if (netpgp->pubring == NULL) {
|
||||
netpgp->pubring = pubring;
|
||||
} else {
|
||||
__ops_append_keyring(netpgp->pubring, pubring);
|
||||
pgp_append_keyring(netpgp->pubring, pubring);
|
||||
}
|
||||
if (needseckey) {
|
||||
netpgp_setvar(netpgp, "sshpubfile", filename);
|
||||
@ -317,7 +317,7 @@ readsshkeys(netpgp_t *netpgp, char *homedir, const char *needseckey)
|
||||
(void) fprintf(stderr, "readsshkeys: bad alloc\n");
|
||||
return 0;
|
||||
}
|
||||
if (!__ops_ssh2_readkeys(netpgp->io, pubring, secring, NULL, filename, hashtype)) {
|
||||
if (!pgp_ssh2_readkeys(netpgp->io, pubring, secring, NULL, filename, hashtype)) {
|
||||
(void) fprintf(stderr, "readsshkeys: can't read sec %s\n", filename);
|
||||
return 0;
|
||||
}
|
||||
@ -329,7 +329,7 @@ readsshkeys(netpgp_t *netpgp, char *homedir, const char *needseckey)
|
||||
|
||||
/* set ssh uid to first one in pubring */
|
||||
static void
|
||||
set_first_pubring(__ops_keyring_t *pubring, char *id, size_t len, int last)
|
||||
set_first_pubring(pgp_keyring_t *pubring, char *id, size_t len, int last)
|
||||
{
|
||||
uint8_t *src;
|
||||
int i;
|
||||
@ -337,7 +337,7 @@ set_first_pubring(__ops_keyring_t *pubring, char *id, size_t len, int last)
|
||||
|
||||
(void) memset(id, 0x0, len);
|
||||
src = pubring->keys[(last) ? pubring->keyc - 1 : 0].sigid;
|
||||
for (i = 0, n = 0 ; i < OPS_KEY_ID_SIZE ; i += 2) {
|
||||
for (i = 0, n = 0 ; i < PGP_KEY_ID_SIZE ; i += 2) {
|
||||
n += snprintf(&id[n], len - n, "%02x%02x", src[i], src[i + 1]);
|
||||
}
|
||||
id[n] = 0x0;
|
||||
@ -415,11 +415,11 @@ get_birthtime(char *s)
|
||||
}
|
||||
|
||||
/* resolve the userid */
|
||||
static const __ops_key_t *
|
||||
resolve_userid(netpgp_t *netpgp, const __ops_keyring_t *keyring, const char *userid)
|
||||
static const pgp_key_t *
|
||||
resolve_userid(netpgp_t *netpgp, const pgp_keyring_t *keyring, const char *userid)
|
||||
{
|
||||
const __ops_key_t *key;
|
||||
__ops_io_t *io;
|
||||
const pgp_key_t *key;
|
||||
pgp_io_t *io;
|
||||
|
||||
if (userid == NULL) {
|
||||
userid = netpgp_getvar(netpgp, "userid");
|
||||
@ -429,7 +429,7 @@ resolve_userid(netpgp_t *netpgp, const __ops_keyring_t *keyring, const char *use
|
||||
userid += 2;
|
||||
}
|
||||
io = netpgp->io;
|
||||
if ((key = __ops_getkeybyname(io, keyring, userid)) == NULL) {
|
||||
if ((key = pgp_getkeybyname(io, keyring, userid)) == NULL) {
|
||||
(void) fprintf(io->errs, "Can't find key '%s'\n", userid);
|
||||
}
|
||||
return key;
|
||||
@ -437,30 +437,30 @@ resolve_userid(netpgp_t *netpgp, const __ops_keyring_t *keyring, const char *use
|
||||
|
||||
/* append a key to a keyring */
|
||||
static int
|
||||
appendkey(__ops_io_t *io, __ops_key_t *key, char *ringfile)
|
||||
appendkey(pgp_io_t *io, pgp_key_t *key, char *ringfile)
|
||||
{
|
||||
__ops_output_t *create;
|
||||
pgp_output_t *create;
|
||||
const unsigned noarmor = 0;
|
||||
int fd;
|
||||
|
||||
if ((fd = __ops_setup_file_append(&create, ringfile)) < 0) {
|
||||
fd = __ops_setup_file_write(&create, ringfile, 0);
|
||||
if ((fd = pgp_setup_file_append(&create, ringfile)) < 0) {
|
||||
fd = pgp_setup_file_write(&create, ringfile, 0);
|
||||
}
|
||||
if (fd < 0) {
|
||||
(void) fprintf(io->errs, "can't open pubring '%s'\n", ringfile);
|
||||
return 0;
|
||||
}
|
||||
if (!__ops_write_xfer_pubkey(create, key, noarmor)) {
|
||||
if (!pgp_write_xfer_pubkey(create, key, noarmor)) {
|
||||
(void) fprintf(io->errs, "Cannot write pubkey\n");
|
||||
return 0;
|
||||
}
|
||||
__ops_teardown_file_write(create, fd);
|
||||
pgp_teardown_file_write(create, fd);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* return 1 if the file contains ascii-armoured text */
|
||||
static unsigned
|
||||
isarmoured(__ops_io_t *io, const char *f, const void *memory, const char *text)
|
||||
isarmoured(pgp_io_t *io, const char *f, const void *memory, const char *text)
|
||||
{
|
||||
unsigned armoured;
|
||||
FILE *fp;
|
||||
@ -572,7 +572,7 @@ format_json_key(FILE *fp, mj_t *obj, const int psigs)
|
||||
mj_t *sub;
|
||||
int i;
|
||||
|
||||
if (__ops_get_debug_level(__FILE__)) {
|
||||
if (pgp_get_debug_level(__FILE__)) {
|
||||
mj_asprint(&s, obj);
|
||||
(void) fprintf(stderr, "formatobj: json is '%s'\n", s);
|
||||
free(s);
|
||||
@ -705,7 +705,7 @@ formatbignum(char *buffer, BIGNUM *bn)
|
||||
int
|
||||
netpgp_init(netpgp_t *netpgp)
|
||||
{
|
||||
__ops_io_t *io;
|
||||
pgp_io_t *io;
|
||||
char id[MAX_ID_LENGTH];
|
||||
char *homedir;
|
||||
char *userid;
|
||||
@ -845,10 +845,10 @@ netpgp_end(netpgp_t *netpgp)
|
||||
free(netpgp->value);
|
||||
}
|
||||
if (netpgp->pubring != NULL) {
|
||||
__ops_keyring_free(netpgp->pubring);
|
||||
pgp_keyring_free(netpgp->pubring);
|
||||
}
|
||||
if (netpgp->secring != NULL) {
|
||||
__ops_keyring_free(netpgp->secring);
|
||||
pgp_keyring_free(netpgp->secring);
|
||||
}
|
||||
free(netpgp->io);
|
||||
return 1;
|
||||
@ -862,7 +862,7 @@ netpgp_list_keys(netpgp_t *netpgp, const int psigs)
|
||||
(void) fprintf(stderr, "No keyring\n");
|
||||
return 0;
|
||||
}
|
||||
return __ops_keyring_list(netpgp->io, netpgp->pubring, psigs);
|
||||
return pgp_keyring_list(netpgp->io, netpgp->pubring, psigs);
|
||||
}
|
||||
|
||||
/* list the keys in a keyring, returning a JSON string */
|
||||
@ -877,7 +877,7 @@ netpgp_list_keys_json(netpgp_t *netpgp, char **json, const int psigs)
|
||||
return 0;
|
||||
}
|
||||
(void) memset(&obj, 0x0, sizeof(obj));
|
||||
if (!__ops_keyring_json(netpgp->io, netpgp->pubring, &obj, psigs)) {
|
||||
if (!pgp_keyring_json(netpgp->io, netpgp->pubring, &obj, psigs)) {
|
||||
(void) fprintf(stderr, "No keys in keyring\n");
|
||||
return 0;
|
||||
}
|
||||
@ -896,7 +896,7 @@ DEFINE_ARRAY(strings_t, char *);
|
||||
int
|
||||
netpgp_match_keys(netpgp_t *netpgp, char *name, const char *fmt, void *vp, const int psigs)
|
||||
{
|
||||
const __ops_key_t *key;
|
||||
const pgp_key_t *key;
|
||||
unsigned k;
|
||||
strings_t pubs;
|
||||
FILE *fp = (FILE *)vp;
|
||||
@ -907,17 +907,17 @@ netpgp_match_keys(netpgp_t *netpgp, char *name, const char *fmt, void *vp, const
|
||||
(void) memset(&pubs, 0x0, sizeof(pubs));
|
||||
k = 0;
|
||||
do {
|
||||
key = __ops_getnextkeybyname(netpgp->io, netpgp->pubring,
|
||||
key = pgp_getnextkeybyname(netpgp->io, netpgp->pubring,
|
||||
name, &k);
|
||||
if (key != NULL) {
|
||||
ALLOC(char *, pubs.v, pubs.size, pubs.c, 10, 10,
|
||||
"netpgp_match_keys", return 0);
|
||||
if (strcmp(fmt, "mr") == 0) {
|
||||
__ops_hkp_sprint_keydata(netpgp->io, netpgp->pubring,
|
||||
pgp_hkp_sprint_keydata(netpgp->io, netpgp->pubring,
|
||||
key, &pubs.v[pubs.c],
|
||||
&key->key.pubkey, psigs);
|
||||
} else {
|
||||
__ops_sprint_keydata(netpgp->io, netpgp->pubring,
|
||||
pgp_sprint_keydata(netpgp->io, netpgp->pubring,
|
||||
key, &pubs.v[pubs.c],
|
||||
"signature ",
|
||||
&key->key.pubkey, psigs);
|
||||
@ -946,7 +946,7 @@ netpgp_match_keys(netpgp_t *netpgp, char *name, const char *fmt, void *vp, const
|
||||
int
|
||||
netpgp_match_keys_json(netpgp_t *netpgp, char **json, char *name, const char *fmt, const int psigs)
|
||||
{
|
||||
const __ops_key_t *key;
|
||||
const pgp_key_t *key;
|
||||
unsigned k;
|
||||
mj_t id_array;
|
||||
int ret;
|
||||
@ -959,19 +959,19 @@ netpgp_match_keys_json(netpgp_t *netpgp, char **json, char *name, const char *fm
|
||||
*json = NULL;
|
||||
mj_create(&id_array, "array");
|
||||
do {
|
||||
key = __ops_getnextkeybyname(netpgp->io, netpgp->pubring,
|
||||
key = pgp_getnextkeybyname(netpgp->io, netpgp->pubring,
|
||||
name, &k);
|
||||
if (key != NULL) {
|
||||
if (strcmp(fmt, "mr") == 0) {
|
||||
#if 0
|
||||
__ops_hkp_sprint_keydata(netpgp->io, netpgp->pubring,
|
||||
pgp_hkp_sprint_keydata(netpgp->io, netpgp->pubring,
|
||||
key, &pubs.v[pubs.c],
|
||||
&key->key.pubkey, psigs);
|
||||
#endif
|
||||
} else {
|
||||
ALLOC(mj_t, id_array.value.v, id_array.size,
|
||||
id_array.c, 10, 10, "netpgp_match_keys_json", return 0);
|
||||
__ops_sprint_mj(netpgp->io, netpgp->pubring,
|
||||
pgp_sprint_mj(netpgp->io, netpgp->pubring,
|
||||
key, &id_array.value.v[id_array.c++],
|
||||
"signature ",
|
||||
&key->key.pubkey, psigs);
|
||||
@ -988,21 +988,21 @@ netpgp_match_keys_json(netpgp_t *netpgp, char **json, char *name, const char *fm
|
||||
int
|
||||
netpgp_match_pubkeys(netpgp_t *netpgp, char *name, void *vp)
|
||||
{
|
||||
const __ops_key_t *key;
|
||||
const pgp_key_t *key;
|
||||
unsigned k;
|
||||
strings_t pubs;
|
||||
FILE *fp = (FILE *)vp;
|
||||
|
||||
(void) memset(&pubs, 0x0, sizeof(pubs));
|
||||
do {
|
||||
key = __ops_getnextkeybyname(netpgp->io, netpgp->pubring,
|
||||
key = pgp_getnextkeybyname(netpgp->io, netpgp->pubring,
|
||||
name, &k);
|
||||
if (key != NULL) {
|
||||
char out[1024 * 64];
|
||||
|
||||
ALLOC(char *, pubs.v, pubs.size, pubs.c, 10, 10,
|
||||
"netpgp_match_pubkeys", return 0);
|
||||
(void) __ops_sprint_pubkey(key, out, sizeof(out));
|
||||
(void) pgp_sprint_pubkey(key, out, sizeof(out));
|
||||
pubs.v[pubs.c++] = netpgp_strdup(out);
|
||||
k += 1;
|
||||
}
|
||||
@ -1020,33 +1020,33 @@ netpgp_match_pubkeys(netpgp_t *netpgp, char *name, void *vp)
|
||||
int
|
||||
netpgp_find_key(netpgp_t *netpgp, char *id)
|
||||
{
|
||||
__ops_io_t *io;
|
||||
pgp_io_t *io;
|
||||
|
||||
io = netpgp->io;
|
||||
if (id == NULL) {
|
||||
(void) fprintf(io->errs, "NULL id to search for\n");
|
||||
return 0;
|
||||
}
|
||||
return __ops_getkeybyname(netpgp->io, netpgp->pubring, id) != NULL;
|
||||
return pgp_getkeybyname(netpgp->io, netpgp->pubring, id) != NULL;
|
||||
}
|
||||
|
||||
/* get a key in a keyring */
|
||||
char *
|
||||
netpgp_get_key(netpgp_t *netpgp, const char *name, const char *fmt)
|
||||
{
|
||||
const __ops_key_t *key;
|
||||
const pgp_key_t *key;
|
||||
char *newkey;
|
||||
|
||||
if ((key = resolve_userid(netpgp, netpgp->pubring, name)) == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
if (strcmp(fmt, "mr") == 0) {
|
||||
return (__ops_hkp_sprint_keydata(netpgp->io, netpgp->pubring,
|
||||
return (pgp_hkp_sprint_keydata(netpgp->io, netpgp->pubring,
|
||||
key, &newkey,
|
||||
&key->key.pubkey,
|
||||
netpgp_getvar(netpgp, "subkey sigs") != NULL) > 0) ? newkey : NULL;
|
||||
}
|
||||
return (__ops_sprint_keydata(netpgp->io, netpgp->pubring,
|
||||
return (pgp_sprint_keydata(netpgp->io, netpgp->pubring,
|
||||
key, &newkey, "signature",
|
||||
&key->key.pubkey,
|
||||
netpgp_getvar(netpgp, "subkey sigs") != NULL) > 0) ? newkey : NULL;
|
||||
@ -1056,14 +1056,14 @@ netpgp_get_key(netpgp_t *netpgp, const char *name, const char *fmt)
|
||||
char *
|
||||
netpgp_export_key(netpgp_t *netpgp, char *name)
|
||||
{
|
||||
const __ops_key_t *key;
|
||||
__ops_io_t *io;
|
||||
const pgp_key_t *key;
|
||||
pgp_io_t *io;
|
||||
|
||||
io = netpgp->io;
|
||||
if ((key = resolve_userid(netpgp, netpgp->pubring, name)) == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
return __ops_export_key(io, key, NULL);
|
||||
return pgp_export_key(io, key, NULL);
|
||||
}
|
||||
|
||||
#define IMPORT_ARMOR_HEAD "-----BEGIN PGP PUBLIC KEY BLOCK-----"
|
||||
@ -1072,28 +1072,28 @@ netpgp_export_key(netpgp_t *netpgp, char *name)
|
||||
int
|
||||
netpgp_import_key(netpgp_t *netpgp, char *f)
|
||||
{
|
||||
__ops_io_t *io;
|
||||
pgp_io_t *io;
|
||||
unsigned realarmor;
|
||||
int done;
|
||||
|
||||
io = netpgp->io;
|
||||
realarmor = isarmoured(io, f, NULL, IMPORT_ARMOR_HEAD);
|
||||
done = __ops_keyring_fileread(netpgp->pubring, realarmor, f);
|
||||
done = pgp_keyring_fileread(netpgp->pubring, realarmor, f);
|
||||
if (!done) {
|
||||
(void) fprintf(io->errs, "Cannot import key from file %s\n", f);
|
||||
return 0;
|
||||
}
|
||||
return __ops_keyring_list(io, netpgp->pubring, 0);
|
||||
return pgp_keyring_list(io, netpgp->pubring, 0);
|
||||
}
|
||||
|
||||
/* generate a new key */
|
||||
int
|
||||
netpgp_generate_key(netpgp_t *netpgp, char *id, int numbits)
|
||||
{
|
||||
__ops_output_t *create;
|
||||
pgp_output_t *create;
|
||||
const unsigned noarmor = 0;
|
||||
__ops_key_t *key;
|
||||
__ops_io_t *io;
|
||||
pgp_key_t *key;
|
||||
pgp_io_t *io;
|
||||
uint8_t *uid;
|
||||
char newid[1024];
|
||||
char filename[MAXPATHLEN];
|
||||
@ -1112,7 +1112,7 @@ netpgp_generate_key(netpgp_t *netpgp, char *id, int numbits)
|
||||
"RSA %d-bit key <%s@localhost>", numbits, getenv("LOGNAME"));
|
||||
}
|
||||
uid = (uint8_t *)newid;
|
||||
key = __ops_rsa_new_selfsign_key(numbits, 65537UL, uid,
|
||||
key = pgp_rsa_new_selfsign_key(numbits, 65537UL, uid,
|
||||
netpgp_getvar(netpgp, "hash"),
|
||||
netpgp_getvar(netpgp, "cipher"));
|
||||
if (key == NULL) {
|
||||
@ -1120,7 +1120,7 @@ netpgp_generate_key(netpgp_t *netpgp, char *id, int numbits)
|
||||
return 0;
|
||||
}
|
||||
cp = NULL;
|
||||
__ops_sprint_keydata(netpgp->io, NULL, key, &cp, "signature ", &key->key.seckey.pubkey, 0);
|
||||
pgp_sprint_keydata(netpgp->io, NULL, key, &cp, "signature ", &key->key.seckey.pubkey, 0);
|
||||
(void) fprintf(stdout, "%s", cp);
|
||||
/* write public key */
|
||||
(void) snprintf(dir, sizeof(dir), "%s/%.16s", netpgp_getvar(netpgp, "homedir"), &cp[38]);
|
||||
@ -1135,26 +1135,26 @@ netpgp_generate_key(netpgp_t *netpgp, char *id, int numbits)
|
||||
return 0;
|
||||
}
|
||||
if (netpgp->pubring != NULL) {
|
||||
__ops_keyring_free(netpgp->pubring);
|
||||
pgp_keyring_free(netpgp->pubring);
|
||||
}
|
||||
/* write secret key */
|
||||
(void) snprintf(ringfile = filename, sizeof(filename), "%s/secring.gpg", dir);
|
||||
if ((fd = __ops_setup_file_append(&create, ringfile)) < 0) {
|
||||
fd = __ops_setup_file_write(&create, ringfile, 0);
|
||||
if ((fd = pgp_setup_file_append(&create, ringfile)) < 0) {
|
||||
fd = pgp_setup_file_write(&create, ringfile, 0);
|
||||
}
|
||||
if (fd < 0) {
|
||||
(void) fprintf(io->errs, "can't append secring '%s'\n", ringfile);
|
||||
return 0;
|
||||
}
|
||||
if (!__ops_write_xfer_seckey(create, key, NULL, 0, noarmor)) {
|
||||
if (!pgp_write_xfer_seckey(create, key, NULL, 0, noarmor)) {
|
||||
(void) fprintf(io->errs, "Cannot write seckey\n");
|
||||
return 0;
|
||||
}
|
||||
__ops_teardown_file_write(create, fd);
|
||||
pgp_teardown_file_write(create, fd);
|
||||
if (netpgp->secring != NULL) {
|
||||
__ops_keyring_free(netpgp->secring);
|
||||
pgp_keyring_free(netpgp->secring);
|
||||
}
|
||||
__ops_keydata_free(key);
|
||||
pgp_keydata_free(key);
|
||||
free(cp);
|
||||
return 1;
|
||||
}
|
||||
@ -1167,10 +1167,10 @@ netpgp_encrypt_file(netpgp_t *netpgp,
|
||||
char *out,
|
||||
int armored)
|
||||
{
|
||||
const __ops_key_t *key;
|
||||
const pgp_key_t *key;
|
||||
const unsigned overwrite = 1;
|
||||
const char *suffix;
|
||||
__ops_io_t *io;
|
||||
pgp_io_t *io;
|
||||
char outname[MAXPATHLEN];
|
||||
|
||||
io = netpgp->io;
|
||||
@ -1188,7 +1188,7 @@ netpgp_encrypt_file(netpgp_t *netpgp,
|
||||
(void) snprintf(outname, sizeof(outname), "%s%s", f, suffix);
|
||||
out = outname;
|
||||
}
|
||||
return (int)__ops_encrypt_file(io, f, out, key, (unsigned)armored,
|
||||
return (int)pgp_encrypt_file(io, f, out, key, (unsigned)armored,
|
||||
overwrite, netpgp_getvar(netpgp, "cipher"));
|
||||
}
|
||||
|
||||
@ -1199,11 +1199,11 @@ int
|
||||
netpgp_decrypt_file(netpgp_t *netpgp, const char *f, char *out, int armored)
|
||||
{
|
||||
const unsigned overwrite = 1;
|
||||
__ops_io_t *io;
|
||||
pgp_io_t *io;
|
||||
unsigned realarmor;
|
||||
unsigned sshkeys;
|
||||
|
||||
__OPS_USED(armored);
|
||||
__PGP_USED(armored);
|
||||
io = netpgp->io;
|
||||
if (f == NULL) {
|
||||
(void) fprintf(io->errs,
|
||||
@ -1212,7 +1212,7 @@ netpgp_decrypt_file(netpgp_t *netpgp, const char *f, char *out, int armored)
|
||||
}
|
||||
realarmor = isarmoured(io, f, NULL, ARMOR_HEAD);
|
||||
sshkeys = (unsigned)(netpgp_getvar(netpgp, "ssh keys") != NULL);
|
||||
return __ops_decrypt_file(netpgp->io, f, out, netpgp->secring,
|
||||
return pgp_decrypt_file(netpgp->io, f, out, netpgp->secring,
|
||||
netpgp->pubring,
|
||||
realarmor, overwrite, sshkeys,
|
||||
netpgp->passfp, get_passphrase_cb);
|
||||
@ -1228,11 +1228,11 @@ netpgp_sign_file(netpgp_t *netpgp,
|
||||
int cleartext,
|
||||
int detached)
|
||||
{
|
||||
const __ops_key_t *keypair;
|
||||
const __ops_key_t *pubkey;
|
||||
__ops_seckey_t *seckey;
|
||||
const pgp_key_t *keypair;
|
||||
const pgp_key_t *pubkey;
|
||||
pgp_seckey_t *seckey;
|
||||
const unsigned overwrite = 1;
|
||||
__ops_io_t *io;
|
||||
pgp_io_t *io;
|
||||
const char *hashalg;
|
||||
int ret;
|
||||
|
||||
@ -1250,25 +1250,25 @@ netpgp_sign_file(netpgp_t *netpgp,
|
||||
do {
|
||||
if (netpgp->passfp == NULL) {
|
||||
/* print out the user id */
|
||||
pubkey = __ops_getkeybyname(io, netpgp->pubring, userid);
|
||||
pubkey = pgp_getkeybyname(io, netpgp->pubring, userid);
|
||||
if (pubkey == NULL) {
|
||||
(void) fprintf(io->errs,
|
||||
"netpgp: warning - using pubkey from secring\n");
|
||||
__ops_print_keydata(io, netpgp->pubring, keypair, "signature ",
|
||||
pgp_print_keydata(io, netpgp->pubring, keypair, "signature ",
|
||||
&keypair->key.seckey.pubkey, 0);
|
||||
} else {
|
||||
__ops_print_keydata(io, netpgp->pubring, pubkey, "signature ",
|
||||
pgp_print_keydata(io, netpgp->pubring, pubkey, "signature ",
|
||||
&pubkey->key.pubkey, 0);
|
||||
}
|
||||
}
|
||||
if (netpgp_getvar(netpgp, "ssh keys") == NULL) {
|
||||
/* now decrypt key */
|
||||
seckey = __ops_decrypt_seckey(keypair, netpgp->passfp);
|
||||
seckey = pgp_decrypt_seckey(keypair, netpgp->passfp);
|
||||
if (seckey == NULL) {
|
||||
(void) fprintf(io->errs, "Bad passphrase\n");
|
||||
}
|
||||
} else {
|
||||
__ops_keyring_t *secring;
|
||||
pgp_keyring_t *secring;
|
||||
|
||||
secring = netpgp->secring;
|
||||
seckey = &secring->keys[0].key.seckey;
|
||||
@ -1276,23 +1276,23 @@ netpgp_sign_file(netpgp_t *netpgp,
|
||||
} while (seckey == NULL);
|
||||
/* sign file */
|
||||
hashalg = netpgp_getvar(netpgp, "hash");
|
||||
if (seckey->pubkey.alg == OPS_PKA_DSA) {
|
||||
if (seckey->pubkey.alg == PGP_PKA_DSA) {
|
||||
hashalg = "sha1";
|
||||
}
|
||||
if (detached) {
|
||||
ret = __ops_sign_detached(io, f, out, seckey, hashalg,
|
||||
ret = pgp_sign_detached(io, f, out, seckey, hashalg,
|
||||
get_birthtime(netpgp_getvar(netpgp, "birthtime")),
|
||||
get_duration(netpgp_getvar(netpgp, "duration")),
|
||||
(unsigned)armored,
|
||||
overwrite);
|
||||
} else {
|
||||
ret = __ops_sign_file(io, f, out, seckey, hashalg,
|
||||
ret = pgp_sign_file(io, f, out, seckey, hashalg,
|
||||
get_birthtime(netpgp_getvar(netpgp, "birthtime")),
|
||||
get_duration(netpgp_getvar(netpgp, "duration")),
|
||||
(unsigned)armored, (unsigned)cleartext,
|
||||
overwrite);
|
||||
}
|
||||
__ops_forget(seckey, (unsigned)sizeof(*seckey));
|
||||
pgp_forget(seckey, (unsigned)sizeof(*seckey));
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -1302,11 +1302,11 @@ netpgp_sign_file(netpgp_t *netpgp,
|
||||
int
|
||||
netpgp_verify_file(netpgp_t *netpgp, const char *in, const char *out, int armored)
|
||||
{
|
||||
__ops_validation_t result;
|
||||
__ops_io_t *io;
|
||||
pgp_validation_t result;
|
||||
pgp_io_t *io;
|
||||
unsigned realarmor;
|
||||
|
||||
__OPS_USED(armored);
|
||||
__PGP_USED(armored);
|
||||
(void) memset(&result, 0x0, sizeof(result));
|
||||
io = netpgp->io;
|
||||
if (in == NULL) {
|
||||
@ -1315,7 +1315,7 @@ netpgp_verify_file(netpgp_t *netpgp, const char *in, const char *out, int armore
|
||||
return 0;
|
||||
}
|
||||
realarmor = isarmoured(io, in, NULL, ARMOR_SIG_HEAD);
|
||||
if (__ops_validate_file(io, &result, in, out, (const int)realarmor, netpgp->pubring)) {
|
||||
if (pgp_validate_file(io, &result, in, out, (const int)realarmor, netpgp->pubring)) {
|
||||
resultp(io, in, &result, netpgp->pubring);
|
||||
return 1;
|
||||
}
|
||||
@ -1345,11 +1345,11 @@ netpgp_sign_memory(netpgp_t *netpgp,
|
||||
const unsigned armored,
|
||||
const unsigned cleartext)
|
||||
{
|
||||
const __ops_key_t *keypair;
|
||||
const __ops_key_t *pubkey;
|
||||
__ops_seckey_t *seckey;
|
||||
__ops_memory_t *signedmem;
|
||||
__ops_io_t *io;
|
||||
const pgp_key_t *keypair;
|
||||
const pgp_key_t *pubkey;
|
||||
pgp_seckey_t *seckey;
|
||||
pgp_memory_t *signedmem;
|
||||
pgp_io_t *io;
|
||||
const char *hashalg;
|
||||
int ret;
|
||||
|
||||
@ -1366,19 +1366,19 @@ netpgp_sign_memory(netpgp_t *netpgp,
|
||||
do {
|
||||
if (netpgp->passfp == NULL) {
|
||||
/* print out the user id */
|
||||
pubkey = __ops_getkeybyname(io, netpgp->pubring, userid);
|
||||
pubkey = pgp_getkeybyname(io, netpgp->pubring, userid);
|
||||
if (pubkey == NULL) {
|
||||
(void) fprintf(io->errs,
|
||||
"netpgp: warning - using pubkey from secring\n");
|
||||
__ops_print_keydata(io, netpgp->pubring, keypair, "signature ",
|
||||
pgp_print_keydata(io, netpgp->pubring, keypair, "signature ",
|
||||
&keypair->key.seckey.pubkey, 0);
|
||||
} else {
|
||||
__ops_print_keydata(io, netpgp->pubring, pubkey, "signature ",
|
||||
pgp_print_keydata(io, netpgp->pubring, pubkey, "signature ",
|
||||
&pubkey->key.pubkey, 0);
|
||||
}
|
||||
}
|
||||
/* now decrypt key */
|
||||
seckey = __ops_decrypt_seckey(keypair, netpgp->passfp);
|
||||
seckey = pgp_decrypt_seckey(keypair, netpgp->passfp);
|
||||
if (seckey == NULL) {
|
||||
(void) fprintf(io->errs, "Bad passphrase\n");
|
||||
}
|
||||
@ -1386,24 +1386,24 @@ netpgp_sign_memory(netpgp_t *netpgp,
|
||||
/* sign file */
|
||||
(void) memset(out, 0x0, outsize);
|
||||
hashalg = netpgp_getvar(netpgp, "hash");
|
||||
if (seckey->pubkey.alg == OPS_PKA_DSA) {
|
||||
if (seckey->pubkey.alg == PGP_PKA_DSA) {
|
||||
hashalg = "sha1";
|
||||
}
|
||||
signedmem = __ops_sign_buf(io, mem, size, seckey,
|
||||
signedmem = pgp_sign_buf(io, mem, size, seckey,
|
||||
get_birthtime(netpgp_getvar(netpgp, "birthtime")),
|
||||
get_duration(netpgp_getvar(netpgp, "duration")),
|
||||
hashalg, armored, cleartext);
|
||||
if (signedmem) {
|
||||
size_t m;
|
||||
|
||||
m = MIN(__ops_mem_len(signedmem), outsize);
|
||||
(void) memcpy(out, __ops_mem_data(signedmem), m);
|
||||
__ops_memory_free(signedmem);
|
||||
m = MIN(pgp_mem_len(signedmem), outsize);
|
||||
(void) memcpy(out, pgp_mem_data(signedmem), m);
|
||||
pgp_memory_free(signedmem);
|
||||
ret = (int)m;
|
||||
} else {
|
||||
ret = 0;
|
||||
}
|
||||
__ops_forget(seckey, (unsigned)sizeof(*seckey));
|
||||
pgp_forget(seckey, (unsigned)sizeof(*seckey));
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -1412,10 +1412,10 @@ int
|
||||
netpgp_verify_memory(netpgp_t *netpgp, const void *in, const size_t size,
|
||||
void *out, size_t outsize, const int armored)
|
||||
{
|
||||
__ops_validation_t result;
|
||||
__ops_memory_t *signedmem;
|
||||
__ops_memory_t *cat;
|
||||
__ops_io_t *io;
|
||||
pgp_validation_t result;
|
||||
pgp_memory_t *signedmem;
|
||||
pgp_memory_t *cat;
|
||||
pgp_io_t *io;
|
||||
size_t m;
|
||||
int ret;
|
||||
|
||||
@ -1426,21 +1426,21 @@ netpgp_verify_memory(netpgp_t *netpgp, const void *in, const size_t size,
|
||||
"netpgp_verify_memory: no memory to verify\n");
|
||||
return 0;
|
||||
}
|
||||
signedmem = __ops_memory_new();
|
||||
__ops_memory_add(signedmem, in, size);
|
||||
signedmem = pgp_memory_new();
|
||||
pgp_memory_add(signedmem, in, size);
|
||||
if (out) {
|
||||
cat = __ops_memory_new();
|
||||
cat = pgp_memory_new();
|
||||
}
|
||||
ret = __ops_validate_mem(io, &result, signedmem,
|
||||
ret = pgp_validate_mem(io, &result, signedmem,
|
||||
(out) ? &cat : NULL,
|
||||
armored, netpgp->pubring);
|
||||
__ops_memory_free(signedmem);
|
||||
pgp_memory_free(signedmem);
|
||||
if (ret) {
|
||||
resultp(io, "<stdin>", &result, netpgp->pubring);
|
||||
if (out) {
|
||||
m = MIN(__ops_mem_len(cat), outsize);
|
||||
(void) memcpy(out, __ops_mem_data(cat), m);
|
||||
__ops_memory_free(cat);
|
||||
m = MIN(pgp_mem_len(cat), outsize);
|
||||
(void) memcpy(out, pgp_mem_data(cat), m);
|
||||
pgp_memory_free(cat);
|
||||
} else {
|
||||
m = 1;
|
||||
}
|
||||
@ -1470,9 +1470,9 @@ netpgp_encrypt_memory(netpgp_t *netpgp,
|
||||
size_t outsize,
|
||||
int armored)
|
||||
{
|
||||
const __ops_key_t *keypair;
|
||||
__ops_memory_t *enc;
|
||||
__ops_io_t *io;
|
||||
const pgp_key_t *keypair;
|
||||
pgp_memory_t *enc;
|
||||
pgp_io_t *io;
|
||||
size_t m;
|
||||
|
||||
io = netpgp->io;
|
||||
@ -1494,11 +1494,11 @@ netpgp_encrypt_memory(netpgp_t *netpgp,
|
||||
"netpgp_encrypt_buf: input size is larger than output size\n");
|
||||
return 0;
|
||||
}
|
||||
enc = __ops_encrypt_buf(io, in, insize, keypair, (unsigned)armored,
|
||||
enc = pgp_encrypt_buf(io, in, insize, keypair, (unsigned)armored,
|
||||
netpgp_getvar(netpgp, "cipher"));
|
||||
m = MIN(__ops_mem_len(enc), outsize);
|
||||
(void) memcpy(out, __ops_mem_data(enc), m);
|
||||
__ops_memory_free(enc);
|
||||
m = MIN(pgp_mem_len(enc), outsize);
|
||||
(void) memcpy(out, pgp_mem_data(enc), m);
|
||||
pgp_memory_free(enc);
|
||||
return (int)m;
|
||||
}
|
||||
|
||||
@ -1507,13 +1507,13 @@ int
|
||||
netpgp_decrypt_memory(netpgp_t *netpgp, const void *input, const size_t insize,
|
||||
char *out, size_t outsize, const int armored)
|
||||
{
|
||||
__ops_memory_t *mem;
|
||||
__ops_io_t *io;
|
||||
pgp_memory_t *mem;
|
||||
pgp_io_t *io;
|
||||
unsigned realarmour;
|
||||
unsigned sshkeys;
|
||||
size_t m;
|
||||
|
||||
__OPS_USED(armored);
|
||||
__PGP_USED(armored);
|
||||
io = netpgp->io;
|
||||
if (input == NULL) {
|
||||
(void) fprintf(io->errs,
|
||||
@ -1522,14 +1522,14 @@ netpgp_decrypt_memory(netpgp_t *netpgp, const void *input, const size_t insize,
|
||||
}
|
||||
realarmour = isarmoured(io, NULL, input, ARMOR_HEAD);
|
||||
sshkeys = (unsigned)(netpgp_getvar(netpgp, "ssh keys") != NULL);
|
||||
mem = __ops_decrypt_buf(netpgp->io, input, insize, netpgp->secring,
|
||||
mem = pgp_decrypt_buf(netpgp->io, input, insize, netpgp->secring,
|
||||
netpgp->pubring,
|
||||
realarmour, sshkeys,
|
||||
netpgp->passfp,
|
||||
get_passphrase_cb);
|
||||
m = MIN(__ops_mem_len(mem), outsize);
|
||||
(void) memcpy(out, __ops_mem_data(mem), m);
|
||||
__ops_memory_free(mem);
|
||||
m = MIN(pgp_mem_len(mem), outsize);
|
||||
(void) memcpy(out, pgp_mem_data(mem), m);
|
||||
pgp_memory_free(mem);
|
||||
return (int)m;
|
||||
}
|
||||
|
||||
@ -1539,31 +1539,31 @@ netpgp_decrypt_memory(netpgp_t *netpgp, const void *input, const size_t insize,
|
||||
int
|
||||
netpgp_set_debug(const char *f)
|
||||
{
|
||||
return __ops_set_debug_level(f);
|
||||
return pgp_set_debug_level(f);
|
||||
}
|
||||
|
||||
/* get the debugging level per filename */
|
||||
int
|
||||
netpgp_get_debug(const char *f)
|
||||
{
|
||||
return __ops_get_debug_level(f);
|
||||
return pgp_get_debug_level(f);
|
||||
}
|
||||
|
||||
/* return the version for the library */
|
||||
const char *
|
||||
netpgp_get_info(const char *type)
|
||||
{
|
||||
return __ops_get_info(type);
|
||||
return pgp_get_info(type);
|
||||
}
|
||||
|
||||
/* list all the packets in a file */
|
||||
int
|
||||
netpgp_list_packets(netpgp_t *netpgp, char *f, int armor, char *pubringname)
|
||||
{
|
||||
__ops_keyring_t *keyring;
|
||||
pgp_keyring_t *keyring;
|
||||
const unsigned noarmor = 0;
|
||||
struct stat st;
|
||||
__ops_io_t *io;
|
||||
pgp_io_t *io;
|
||||
char ringname[MAXPATHLEN];
|
||||
char *homedir;
|
||||
int ret;
|
||||
@ -1587,7 +1587,7 @@ netpgp_list_packets(netpgp_t *netpgp, char *f, int armor, char *pubringname)
|
||||
(void) fprintf(io->errs, "netpgp_list_packets: bad alloc\n");
|
||||
return 0;
|
||||
}
|
||||
if (!__ops_keyring_fileread(keyring, noarmor, pubringname)) {
|
||||
if (!pgp_keyring_fileread(keyring, noarmor, pubringname)) {
|
||||
free(keyring);
|
||||
(void) fprintf(io->errs, "Cannot read pub keyring %s\n",
|
||||
pubringname);
|
||||
@ -1595,7 +1595,7 @@ netpgp_list_packets(netpgp_t *netpgp, char *f, int armor, char *pubringname)
|
||||
}
|
||||
netpgp->pubring = keyring;
|
||||
netpgp_setvar(netpgp, "pubring", pubringname);
|
||||
ret = __ops_list_packets(io, f, (unsigned)armor,
|
||||
ret = pgp_list_packets(io, f, (unsigned)armor,
|
||||
netpgp->secring,
|
||||
netpgp->pubring,
|
||||
netpgp->passfp,
|
||||
@ -1627,7 +1627,7 @@ netpgp_setvar(netpgp_t *netpgp, const char *name, const char *value)
|
||||
}
|
||||
/* sanity checks for range of values */
|
||||
if (strcmp(name, "hash") == 0 || strcmp(name, "algorithm") == 0) {
|
||||
if (__ops_str_to_hash_alg(newval) == OPS_HASH_UNKNOWN) {
|
||||
if (pgp_str_to_hash_alg(newval) == PGP_HASH_UNKNOWN) {
|
||||
free(newval);
|
||||
return 0;
|
||||
}
|
||||
@ -1714,9 +1714,9 @@ netpgp_set_homedir(netpgp_t *netpgp, char *home, const char *subdir, const int q
|
||||
int
|
||||
netpgp_validate_sigs(netpgp_t *netpgp)
|
||||
{
|
||||
__ops_validation_t result;
|
||||
pgp_validation_t result;
|
||||
|
||||
return (int)__ops_validate_all_sigs(&result, netpgp->pubring, NULL);
|
||||
return (int)pgp_validate_all_sigs(&result, netpgp->pubring, NULL);
|
||||
}
|
||||
|
||||
/* print the json out on 'fp' */
|
||||
@ -1755,14 +1755,14 @@ netpgp_format_json(void *vp, const char *json, const int psigs)
|
||||
int
|
||||
netpgp_write_sshkey(netpgp_t *netpgp, char *s, const char *userid, char *out, size_t size)
|
||||
{
|
||||
const __ops_key_t *key;
|
||||
__ops_keyring_t *keyring;
|
||||
__ops_io_t *io;
|
||||
const pgp_key_t *key;
|
||||
pgp_keyring_t *keyring;
|
||||
pgp_io_t *io;
|
||||
unsigned k;
|
||||
size_t cc;
|
||||
char f[MAXPATHLEN];
|
||||
|
||||
if ((io = calloc(1, sizeof(__ops_io_t))) == NULL) {
|
||||
if ((io = calloc(1, sizeof(pgp_io_t))) == NULL) {
|
||||
(void) fprintf(stderr, "netpgp_save_sshpub: bad alloc 1\n");
|
||||
return 0;
|
||||
}
|
||||
@ -1776,18 +1776,18 @@ netpgp_write_sshkey(netpgp_t *netpgp, char *s, const char *userid, char *out, si
|
||||
(void) fprintf(stderr, "netpgp_save_sshpub: bad alloc 2\n");
|
||||
return 0;
|
||||
}
|
||||
if (!__ops_keyring_fileread(netpgp->pubring = keyring, 1, f)) {
|
||||
if (!pgp_keyring_fileread(netpgp->pubring = keyring, 1, f)) {
|
||||
(void) fprintf(stderr, "can't import key\n");
|
||||
return 0;
|
||||
}
|
||||
/* get rsa key */
|
||||
k = 0;
|
||||
key = __ops_getnextkeybyname(netpgp->io, netpgp->pubring, userid, &k);
|
||||
key = pgp_getnextkeybyname(netpgp->io, netpgp->pubring, userid, &k);
|
||||
if (key == NULL) {
|
||||
(void) fprintf(stderr, "no key found for '%s'\n", userid);
|
||||
return 0;
|
||||
}
|
||||
if (key->key.pubkey.alg != OPS_PKA_RSA) {
|
||||
if (key->key.pubkey.alg != PGP_PKA_RSA) {
|
||||
/* we're not interested in supporting DSA either :-) */
|
||||
(void) fprintf(stderr, "key not RSA '%s'\n", userid);
|
||||
return 0;
|
||||
|
@ -38,30 +38,30 @@
|
||||
#endif
|
||||
|
||||
/* for silencing unused parameter warnings */
|
||||
#define __OPS_USED(x) /*LINTED*/(void)&(x)
|
||||
#define __PGP_USED(x) /*LINTED*/(void)&(x)
|
||||
|
||||
#ifndef __UNCONST
|
||||
#define __UNCONST(a) ((void *)(unsigned long)(const void *)(a))
|
||||
#endif
|
||||
|
||||
/* number of elements in an array */
|
||||
#define OPS_ARRAY_SIZE(a) (sizeof(a)/sizeof(*(a)))
|
||||
#define PGP_ARRAY_SIZE(a) (sizeof(a)/sizeof(*(a)))
|
||||
|
||||
void hexdump(FILE *, const char *, const uint8_t *, size_t);
|
||||
|
||||
const char *__ops_str_from_map(int, __ops_map_t *);
|
||||
const char *pgp_str_from_map(int, pgp_map_t *);
|
||||
|
||||
int __ops_set_debug_level(const char *);
|
||||
int __ops_get_debug_level(const char *);
|
||||
int pgp_set_debug_level(const char *);
|
||||
int pgp_get_debug_level(const char *);
|
||||
|
||||
void *__ops_new(size_t);
|
||||
void *pgp_new(size_t);
|
||||
|
||||
#define NETPGP_BUFSIZ 8192
|
||||
|
||||
#define CALLBACK(t, cbinfo, pkt) do { \
|
||||
(pkt)->tag = (t); \
|
||||
if (__ops_callback(pkt, cbinfo) == OPS_RELEASE_MEMORY) { \
|
||||
__ops_parser_content_free(pkt); \
|
||||
if (pgp_callback(pkt, cbinfo) == PGP_RELEASE_MEMORY) { \
|
||||
pgp_parser_content_free(pkt); \
|
||||
} \
|
||||
} while(/* CONSTCOND */0)
|
||||
|
||||
|
@ -48,8 +48,8 @@
|
||||
#endif
|
||||
|
||||
/* SHA1 Hash Size */
|
||||
#define OPS_SHA1_HASH_SIZE SHA_DIGEST_LENGTH
|
||||
#define OPS_SHA256_HASH_SIZE SHA256_DIGEST_LENGTH
|
||||
#define OPS_CHECKHASH_SIZE OPS_SHA1_HASH_SIZE
|
||||
#define PGP_SHA1_HASH_SIZE SHA_DIGEST_LENGTH
|
||||
#define PGP_SHA256_HASH_SIZE SHA256_DIGEST_LENGTH
|
||||
#define PGP_CHECKHASH_SIZE PGP_SHA1_HASH_SIZE
|
||||
|
||||
#endif /* NETPGPDIGEST_H_ */
|
||||
|
@ -34,36 +34,36 @@
|
||||
#include "signature.h"
|
||||
#include "packet-show.h"
|
||||
|
||||
typedef struct __ops_validation_t {
|
||||
typedef struct pgp_validation_t {
|
||||
unsigned validc;
|
||||
__ops_sig_info_t *valid_sigs;
|
||||
pgp_sig_info_t *valid_sigs;
|
||||
unsigned invalidc;
|
||||
__ops_sig_info_t *invalid_sigs;
|
||||
pgp_sig_info_t *invalid_sigs;
|
||||
unsigned unknownc;
|
||||
__ops_sig_info_t *unknown_sigs;
|
||||
pgp_sig_info_t *unknown_sigs;
|
||||
time_t birthtime;
|
||||
time_t duration;
|
||||
} __ops_validation_t;
|
||||
} pgp_validation_t;
|
||||
|
||||
void __ops_validate_result_free(__ops_validation_t *);
|
||||
void pgp_validate_result_free(pgp_validation_t *);
|
||||
|
||||
unsigned
|
||||
__ops_validate_key_sigs(__ops_validation_t *,
|
||||
const __ops_key_t *,
|
||||
const __ops_keyring_t *,
|
||||
__ops_cb_ret_t cb(const __ops_packet_t *, __ops_cbdata_t *));
|
||||
pgp_validate_key_sigs(pgp_validation_t *,
|
||||
const pgp_key_t *,
|
||||
const pgp_keyring_t *,
|
||||
pgp_cb_ret_t cb(const pgp_packet_t *, pgp_cbdata_t *));
|
||||
|
||||
unsigned
|
||||
__ops_validate_all_sigs(__ops_validation_t *,
|
||||
const __ops_keyring_t *,
|
||||
__ops_cb_ret_t cb(const __ops_packet_t *, __ops_cbdata_t *));
|
||||
pgp_validate_all_sigs(pgp_validation_t *,
|
||||
const pgp_keyring_t *,
|
||||
pgp_cb_ret_t cb(const pgp_packet_t *, pgp_cbdata_t *));
|
||||
|
||||
unsigned __ops_check_sig(const uint8_t *,
|
||||
unsigned, const __ops_sig_t *, const __ops_pubkey_t *);
|
||||
unsigned pgp_check_sig(const uint8_t *,
|
||||
unsigned, const pgp_sig_t *, const pgp_pubkey_t *);
|
||||
|
||||
const char *__ops_get_info(const char *type);
|
||||
const char *pgp_get_info(const char *type);
|
||||
|
||||
int __ops_asprintf(char **, const char *, ...);
|
||||
int pgp_asprintf(char **, const char *, ...);
|
||||
|
||||
void netpgp_log(const char *, ...);
|
||||
|
||||
|
@ -57,7 +57,7 @@
|
||||
|
||||
#if defined(__NetBSD__)
|
||||
__COPYRIGHT("@(#) Copyright (c) 2009 The NetBSD Foundation, Inc. All rights reserved.");
|
||||
__RCSID("$NetBSD: openssl_crypto.c,v 1.32 2010/11/07 06:56:52 agc Exp $");
|
||||
__RCSID("$NetBSD: openssl_crypto.c,v 1.33 2010/11/07 08:39:59 agc Exp $");
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_OPENSSL_DSA_H
|
||||
@ -91,7 +91,7 @@ __RCSID("$NetBSD: openssl_crypto.c,v 1.32 2010/11/07 06:56:52 agc Exp $");
|
||||
|
||||
|
||||
static void
|
||||
test_seckey(const __ops_seckey_t *seckey)
|
||||
test_seckey(const pgp_seckey_t *seckey)
|
||||
{
|
||||
RSA *test = RSA_new();
|
||||
|
||||
@ -110,7 +110,7 @@ test_seckey(const __ops_seckey_t *seckey)
|
||||
}
|
||||
|
||||
static int
|
||||
md5_init(__ops_hash_t *hash)
|
||||
md5_init(pgp_hash_t *hash)
|
||||
{
|
||||
if (hash->data) {
|
||||
(void) fprintf(stderr, "md5_init: hash data non-null\n");
|
||||
@ -124,13 +124,13 @@ md5_init(__ops_hash_t *hash)
|
||||
}
|
||||
|
||||
static void
|
||||
md5_add(__ops_hash_t *hash, const uint8_t *data, unsigned length)
|
||||
md5_add(pgp_hash_t *hash, const uint8_t *data, unsigned length)
|
||||
{
|
||||
MD5_Update(hash->data, data, length);
|
||||
}
|
||||
|
||||
static unsigned
|
||||
md5_finish(__ops_hash_t *hash, uint8_t *out)
|
||||
md5_finish(pgp_hash_t *hash, uint8_t *out)
|
||||
{
|
||||
MD5_Final(out, hash->data);
|
||||
free(hash->data);
|
||||
@ -138,8 +138,8 @@ md5_finish(__ops_hash_t *hash, uint8_t *out)
|
||||
return 16;
|
||||
}
|
||||
|
||||
static const __ops_hash_t md5 = {
|
||||
OPS_HASH_MD5,
|
||||
static const pgp_hash_t md5 = {
|
||||
PGP_HASH_MD5,
|
||||
MD5_DIGEST_LENGTH,
|
||||
"MD5",
|
||||
md5_init,
|
||||
@ -154,13 +154,13 @@ static const __ops_hash_t md5 = {
|
||||
\param hash Hash to initialise
|
||||
*/
|
||||
void
|
||||
__ops_hash_md5(__ops_hash_t *hash)
|
||||
pgp_hash_md5(pgp_hash_t *hash)
|
||||
{
|
||||
*hash = md5;
|
||||
}
|
||||
|
||||
static int
|
||||
sha1_init(__ops_hash_t *hash)
|
||||
sha1_init(pgp_hash_t *hash)
|
||||
{
|
||||
if (hash->data) {
|
||||
(void) fprintf(stderr, "sha1_init: hash data non-null\n");
|
||||
@ -174,29 +174,29 @@ sha1_init(__ops_hash_t *hash)
|
||||
}
|
||||
|
||||
static void
|
||||
sha1_add(__ops_hash_t *hash, const uint8_t *data, unsigned length)
|
||||
sha1_add(pgp_hash_t *hash, const uint8_t *data, unsigned length)
|
||||
{
|
||||
if (__ops_get_debug_level(__FILE__)) {
|
||||
if (pgp_get_debug_level(__FILE__)) {
|
||||
hexdump(stderr, "sha1_add", data, length);
|
||||
}
|
||||
SHA1_Update(hash->data, data, length);
|
||||
}
|
||||
|
||||
static unsigned
|
||||
sha1_finish(__ops_hash_t *hash, uint8_t *out)
|
||||
sha1_finish(pgp_hash_t *hash, uint8_t *out)
|
||||
{
|
||||
SHA1_Final(out, hash->data);
|
||||
if (__ops_get_debug_level(__FILE__)) {
|
||||
hexdump(stderr, "sha1_finish", out, OPS_SHA1_HASH_SIZE);
|
||||
if (pgp_get_debug_level(__FILE__)) {
|
||||
hexdump(stderr, "sha1_finish", out, PGP_SHA1_HASH_SIZE);
|
||||
}
|
||||
free(hash->data);
|
||||
hash->data = NULL;
|
||||
return OPS_SHA1_HASH_SIZE;
|
||||
return PGP_SHA1_HASH_SIZE;
|
||||
}
|
||||
|
||||
static const __ops_hash_t sha1 = {
|
||||
OPS_HASH_SHA1,
|
||||
OPS_SHA1_HASH_SIZE,
|
||||
static const pgp_hash_t sha1 = {
|
||||
PGP_HASH_SHA1,
|
||||
PGP_SHA1_HASH_SIZE,
|
||||
"SHA1",
|
||||
sha1_init,
|
||||
sha1_add,
|
||||
@ -210,13 +210,13 @@ static const __ops_hash_t sha1 = {
|
||||
\param hash Hash to initialise
|
||||
*/
|
||||
void
|
||||
__ops_hash_sha1(__ops_hash_t *hash)
|
||||
pgp_hash_sha1(pgp_hash_t *hash)
|
||||
{
|
||||
*hash = sha1;
|
||||
}
|
||||
|
||||
static int
|
||||
sha256_init(__ops_hash_t *hash)
|
||||
sha256_init(pgp_hash_t *hash)
|
||||
{
|
||||
if (hash->data) {
|
||||
(void) fprintf(stderr, "sha256_init: hash data non-null\n");
|
||||
@ -230,19 +230,19 @@ sha256_init(__ops_hash_t *hash)
|
||||
}
|
||||
|
||||
static void
|
||||
sha256_add(__ops_hash_t *hash, const uint8_t *data, unsigned length)
|
||||
sha256_add(pgp_hash_t *hash, const uint8_t *data, unsigned length)
|
||||
{
|
||||
if (__ops_get_debug_level(__FILE__)) {
|
||||
if (pgp_get_debug_level(__FILE__)) {
|
||||
hexdump(stderr, "sha256_add", data, length);
|
||||
}
|
||||
SHA256_Update(hash->data, data, length);
|
||||
}
|
||||
|
||||
static unsigned
|
||||
sha256_finish(__ops_hash_t *hash, uint8_t *out)
|
||||
sha256_finish(pgp_hash_t *hash, uint8_t *out)
|
||||
{
|
||||
SHA256_Final(out, hash->data);
|
||||
if (__ops_get_debug_level(__FILE__)) {
|
||||
if (pgp_get_debug_level(__FILE__)) {
|
||||
hexdump(stderr, "sha1_finish", out, SHA256_DIGEST_LENGTH);
|
||||
}
|
||||
free(hash->data);
|
||||
@ -250,8 +250,8 @@ sha256_finish(__ops_hash_t *hash, uint8_t *out)
|
||||
return SHA256_DIGEST_LENGTH;
|
||||
}
|
||||
|
||||
static const __ops_hash_t sha256 = {
|
||||
OPS_HASH_SHA256,
|
||||
static const pgp_hash_t sha256 = {
|
||||
PGP_HASH_SHA256,
|
||||
SHA256_DIGEST_LENGTH,
|
||||
"SHA256",
|
||||
sha256_init,
|
||||
@ -261,7 +261,7 @@ static const __ops_hash_t sha256 = {
|
||||
};
|
||||
|
||||
void
|
||||
__ops_hash_sha256(__ops_hash_t *hash)
|
||||
pgp_hash_sha256(pgp_hash_t *hash)
|
||||
{
|
||||
*hash = sha256;
|
||||
}
|
||||
@ -270,7 +270,7 @@ __ops_hash_sha256(__ops_hash_t *hash)
|
||||
* SHA384
|
||||
*/
|
||||
static int
|
||||
sha384_init(__ops_hash_t *hash)
|
||||
sha384_init(pgp_hash_t *hash)
|
||||
{
|
||||
if (hash->data) {
|
||||
(void) fprintf(stderr, "sha384_init: hash data non-null\n");
|
||||
@ -284,19 +284,19 @@ sha384_init(__ops_hash_t *hash)
|
||||
}
|
||||
|
||||
static void
|
||||
sha384_add(__ops_hash_t *hash, const uint8_t *data, unsigned length)
|
||||
sha384_add(pgp_hash_t *hash, const uint8_t *data, unsigned length)
|
||||
{
|
||||
if (__ops_get_debug_level(__FILE__)) {
|
||||
if (pgp_get_debug_level(__FILE__)) {
|
||||
hexdump(stderr, "sha384_add", data, length);
|
||||
}
|
||||
SHA384_Update(hash->data, data, length);
|
||||
}
|
||||
|
||||
static unsigned
|
||||
sha384_finish(__ops_hash_t *hash, uint8_t *out)
|
||||
sha384_finish(pgp_hash_t *hash, uint8_t *out)
|
||||
{
|
||||
SHA384_Final(out, hash->data);
|
||||
if (__ops_get_debug_level(__FILE__)) {
|
||||
if (pgp_get_debug_level(__FILE__)) {
|
||||
hexdump(stderr, "sha384_finish", out, SHA384_DIGEST_LENGTH);
|
||||
}
|
||||
free(hash->data);
|
||||
@ -304,8 +304,8 @@ sha384_finish(__ops_hash_t *hash, uint8_t *out)
|
||||
return SHA384_DIGEST_LENGTH;
|
||||
}
|
||||
|
||||
static const __ops_hash_t sha384 = {
|
||||
OPS_HASH_SHA384,
|
||||
static const pgp_hash_t sha384 = {
|
||||
PGP_HASH_SHA384,
|
||||
SHA384_DIGEST_LENGTH,
|
||||
"SHA384",
|
||||
sha384_init,
|
||||
@ -315,7 +315,7 @@ static const __ops_hash_t sha384 = {
|
||||
};
|
||||
|
||||
void
|
||||
__ops_hash_sha384(__ops_hash_t *hash)
|
||||
pgp_hash_sha384(pgp_hash_t *hash)
|
||||
{
|
||||
*hash = sha384;
|
||||
}
|
||||
@ -324,7 +324,7 @@ __ops_hash_sha384(__ops_hash_t *hash)
|
||||
* SHA512
|
||||
*/
|
||||
static int
|
||||
sha512_init(__ops_hash_t *hash)
|
||||
sha512_init(pgp_hash_t *hash)
|
||||
{
|
||||
if (hash->data) {
|
||||
(void) fprintf(stderr, "sha512_init: hash data non-null\n");
|
||||
@ -338,19 +338,19 @@ sha512_init(__ops_hash_t *hash)
|
||||
}
|
||||
|
||||
static void
|
||||
sha512_add(__ops_hash_t *hash, const uint8_t *data, unsigned length)
|
||||
sha512_add(pgp_hash_t *hash, const uint8_t *data, unsigned length)
|
||||
{
|
||||
if (__ops_get_debug_level(__FILE__)) {
|
||||
if (pgp_get_debug_level(__FILE__)) {
|
||||
hexdump(stderr, "sha512_add", data, length);
|
||||
}
|
||||
SHA512_Update(hash->data, data, length);
|
||||
}
|
||||
|
||||
static unsigned
|
||||
sha512_finish(__ops_hash_t *hash, uint8_t *out)
|
||||
sha512_finish(pgp_hash_t *hash, uint8_t *out)
|
||||
{
|
||||
SHA512_Final(out, hash->data);
|
||||
if (__ops_get_debug_level(__FILE__)) {
|
||||
if (pgp_get_debug_level(__FILE__)) {
|
||||
hexdump(stderr, "sha512_finish", out, SHA512_DIGEST_LENGTH);
|
||||
}
|
||||
free(hash->data);
|
||||
@ -358,8 +358,8 @@ sha512_finish(__ops_hash_t *hash, uint8_t *out)
|
||||
return SHA512_DIGEST_LENGTH;
|
||||
}
|
||||
|
||||
static const __ops_hash_t sha512 = {
|
||||
OPS_HASH_SHA512,
|
||||
static const pgp_hash_t sha512 = {
|
||||
PGP_HASH_SHA512,
|
||||
SHA512_DIGEST_LENGTH,
|
||||
"SHA512",
|
||||
sha512_init,
|
||||
@ -369,7 +369,7 @@ static const __ops_hash_t sha512 = {
|
||||
};
|
||||
|
||||
void
|
||||
__ops_hash_sha512(__ops_hash_t *hash)
|
||||
pgp_hash_sha512(pgp_hash_t *hash)
|
||||
{
|
||||
*hash = sha512;
|
||||
}
|
||||
@ -379,7 +379,7 @@ __ops_hash_sha512(__ops_hash_t *hash)
|
||||
*/
|
||||
|
||||
static int
|
||||
sha224_init(__ops_hash_t *hash)
|
||||
sha224_init(pgp_hash_t *hash)
|
||||
{
|
||||
if (hash->data) {
|
||||
(void) fprintf(stderr, "sha224_init: hash data non-null\n");
|
||||
@ -393,19 +393,19 @@ sha224_init(__ops_hash_t *hash)
|
||||
}
|
||||
|
||||
static void
|
||||
sha224_add(__ops_hash_t *hash, const uint8_t *data, unsigned length)
|
||||
sha224_add(pgp_hash_t *hash, const uint8_t *data, unsigned length)
|
||||
{
|
||||
if (__ops_get_debug_level(__FILE__)) {
|
||||
if (pgp_get_debug_level(__FILE__)) {
|
||||
hexdump(stderr, "sha224_add", data, length);
|
||||
}
|
||||
SHA224_Update(hash->data, data, length);
|
||||
}
|
||||
|
||||
static unsigned
|
||||
sha224_finish(__ops_hash_t *hash, uint8_t *out)
|
||||
sha224_finish(pgp_hash_t *hash, uint8_t *out)
|
||||
{
|
||||
SHA224_Final(out, hash->data);
|
||||
if (__ops_get_debug_level(__FILE__)) {
|
||||
if (pgp_get_debug_level(__FILE__)) {
|
||||
hexdump(stderr, "sha224_finish", out, SHA224_DIGEST_LENGTH);
|
||||
}
|
||||
free(hash->data);
|
||||
@ -413,8 +413,8 @@ sha224_finish(__ops_hash_t *hash, uint8_t *out)
|
||||
return SHA224_DIGEST_LENGTH;
|
||||
}
|
||||
|
||||
static const __ops_hash_t sha224 = {
|
||||
OPS_HASH_SHA224,
|
||||
static const pgp_hash_t sha224 = {
|
||||
PGP_HASH_SHA224,
|
||||
SHA224_DIGEST_LENGTH,
|
||||
"SHA224",
|
||||
sha224_init,
|
||||
@ -424,15 +424,15 @@ static const __ops_hash_t sha224 = {
|
||||
};
|
||||
|
||||
void
|
||||
__ops_hash_sha224(__ops_hash_t *hash)
|
||||
pgp_hash_sha224(pgp_hash_t *hash)
|
||||
{
|
||||
*hash = sha224;
|
||||
}
|
||||
|
||||
unsigned
|
||||
__ops_dsa_verify(const uint8_t *hash, size_t hash_length,
|
||||
const __ops_dsa_sig_t *sig,
|
||||
const __ops_dsa_pubkey_t *dsa)
|
||||
pgp_dsa_verify(const uint8_t *hash, size_t hash_length,
|
||||
const pgp_dsa_sig_t *sig,
|
||||
const pgp_dsa_pubkey_t *dsa)
|
||||
{
|
||||
unsigned qlen;
|
||||
DSA_SIG *osig;
|
||||
@ -449,7 +449,7 @@ __ops_dsa_verify(const uint8_t *hash, size_t hash_length,
|
||||
odsa->g = dsa->g;
|
||||
odsa->pub_key = dsa->y;
|
||||
|
||||
if (__ops_get_debug_level(__FILE__)) {
|
||||
if (pgp_get_debug_level(__FILE__)) {
|
||||
hexdump(stderr, "input hash", hash, hash_length);
|
||||
(void) fprintf(stderr, "Q=%d\n", BN_num_bytes(odsa->q));
|
||||
}
|
||||
@ -457,11 +457,11 @@ __ops_dsa_verify(const uint8_t *hash, size_t hash_length,
|
||||
hash_length = qlen;
|
||||
}
|
||||
ret = DSA_do_verify(hash, (int)hash_length, osig, odsa);
|
||||
if (__ops_get_debug_level(__FILE__)) {
|
||||
if (pgp_get_debug_level(__FILE__)) {
|
||||
(void) fprintf(stderr, "ret=%d\n", ret);
|
||||
}
|
||||
if (ret < 0) {
|
||||
(void) fprintf(stderr, "__ops_dsa_verify: DSA verification\n");
|
||||
(void) fprintf(stderr, "pgp_dsa_verify: DSA verification\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -484,10 +484,10 @@ __ops_dsa_verify(const uint8_t *hash, size_t hash_length,
|
||||
\return size of recovered message digest
|
||||
*/
|
||||
int
|
||||
__ops_rsa_public_decrypt(uint8_t *out,
|
||||
pgp_rsa_public_decrypt(uint8_t *out,
|
||||
const uint8_t *in,
|
||||
size_t length,
|
||||
const __ops_rsa_pubkey_t *pubkey)
|
||||
const pgp_rsa_pubkey_t *pubkey)
|
||||
{
|
||||
RSA *orsa;
|
||||
int n;
|
||||
@ -515,11 +515,11 @@ __ops_rsa_public_decrypt(uint8_t *out,
|
||||
\return number of bytes decrypted
|
||||
*/
|
||||
int
|
||||
__ops_rsa_private_encrypt(uint8_t *out,
|
||||
pgp_rsa_private_encrypt(uint8_t *out,
|
||||
const uint8_t *in,
|
||||
size_t length,
|
||||
const __ops_rsa_seckey_t *seckey,
|
||||
const __ops_rsa_pubkey_t *pubkey)
|
||||
const pgp_rsa_seckey_t *seckey,
|
||||
const pgp_rsa_pubkey_t *pubkey)
|
||||
{
|
||||
RSA *orsa;
|
||||
int n;
|
||||
@ -534,7 +534,7 @@ __ops_rsa_private_encrypt(uint8_t *out,
|
||||
orsa->e = BN_dup(pubkey->e);
|
||||
/* If this isn't set, it's very likely that the programmer hasn't */
|
||||
/* decrypted the secret key. RSA_check_key segfaults in that case. */
|
||||
/* Use __ops_decrypt_seckey() to do that. */
|
||||
/* Use pgp_decrypt_seckey() to do that. */
|
||||
if (orsa->d == NULL) {
|
||||
(void) fprintf(stderr, "orsa is not set\n");
|
||||
return 0;
|
||||
@ -564,11 +564,11 @@ __ops_rsa_private_encrypt(uint8_t *out,
|
||||
\return size of recovered plaintext
|
||||
*/
|
||||
int
|
||||
__ops_rsa_private_decrypt(uint8_t *out,
|
||||
pgp_rsa_private_decrypt(uint8_t *out,
|
||||
const uint8_t *in,
|
||||
size_t length,
|
||||
const __ops_rsa_seckey_t *seckey,
|
||||
const __ops_rsa_pubkey_t *pubkey)
|
||||
const pgp_rsa_seckey_t *seckey,
|
||||
const pgp_rsa_pubkey_t *pubkey)
|
||||
{
|
||||
RSA *keypair;
|
||||
int n;
|
||||
@ -590,8 +590,8 @@ __ops_rsa_private_decrypt(uint8_t *out,
|
||||
|
||||
n = RSA_private_decrypt((int)length, in, out, keypair, RSA_NO_PADDING);
|
||||
|
||||
if (__ops_get_debug_level(__FILE__)) {
|
||||
printf("__ops_rsa_private_decrypt: n=%d\n",n);
|
||||
if (pgp_get_debug_level(__FILE__)) {
|
||||
printf("pgp_rsa_private_decrypt: n=%d\n",n);
|
||||
}
|
||||
|
||||
errbuf[0] = '\0';
|
||||
@ -616,23 +616,23 @@ __ops_rsa_private_decrypt(uint8_t *out,
|
||||
\param pubkey RSA Public Key
|
||||
*/
|
||||
int
|
||||
__ops_rsa_public_encrypt(uint8_t *out,
|
||||
pgp_rsa_public_encrypt(uint8_t *out,
|
||||
const uint8_t *in,
|
||||
size_t length,
|
||||
const __ops_rsa_pubkey_t *pubkey)
|
||||
const pgp_rsa_pubkey_t *pubkey)
|
||||
{
|
||||
RSA *orsa;
|
||||
int n;
|
||||
|
||||
/* printf("__ops_rsa_public_encrypt: length=%ld\n", length); */
|
||||
/* printf("pgp_rsa_public_encrypt: length=%ld\n", length); */
|
||||
|
||||
orsa = RSA_new();
|
||||
orsa->n = pubkey->n;
|
||||
orsa->e = pubkey->e;
|
||||
|
||||
/* printf("len: %ld\n", length); */
|
||||
/* __ops_print_bn("n: ", orsa->n); */
|
||||
/* __ops_print_bn("e: ", orsa->e); */
|
||||
/* pgp_print_bn("n: ", orsa->n); */
|
||||
/* pgp_print_bn("e: ", orsa->e); */
|
||||
n = RSA_public_encrypt((int)length, in, out, orsa, RSA_NO_PADDING);
|
||||
|
||||
if (n == -1) {
|
||||
@ -650,11 +650,11 @@ __ops_rsa_public_encrypt(uint8_t *out,
|
||||
/**
|
||||
\ingroup Core_Crypto
|
||||
\brief Finalise openssl
|
||||
\note Would usually call __ops_finish() instead
|
||||
\sa __ops_finish()
|
||||
\note Would usually call pgp_finish() instead
|
||||
\sa pgp_finish()
|
||||
*/
|
||||
void
|
||||
__ops_crypto_finish(void)
|
||||
pgp_crypto_finish(void)
|
||||
{
|
||||
CRYPTO_cleanup_all_ex_data();
|
||||
ERR_remove_state((unsigned long)0);
|
||||
@ -667,7 +667,7 @@ __ops_crypto_finish(void)
|
||||
\return Hash name
|
||||
*/
|
||||
const char *
|
||||
__ops_text_from_hash(__ops_hash_t *hash)
|
||||
pgp_text_from_hash(pgp_hash_t *hash)
|
||||
{
|
||||
return hash->name;
|
||||
}
|
||||
@ -679,46 +679,46 @@ __ops_text_from_hash(__ops_hash_t *hash)
|
||||
\param e Public Exponent
|
||||
\param keydata Pointer to keydata struct to hold new key
|
||||
\return 1 if key generated successfully; otherwise 0
|
||||
\note It is the caller's responsibility to call __ops_keydata_free(keydata)
|
||||
\note It is the caller's responsibility to call pgp_keydata_free(keydata)
|
||||
*/
|
||||
static unsigned
|
||||
rsa_generate_keypair(__ops_key_t *keydata,
|
||||
rsa_generate_keypair(pgp_key_t *keydata,
|
||||
const int numbits,
|
||||
const unsigned long e,
|
||||
const char *hashalg,
|
||||
const char *cipher)
|
||||
{
|
||||
__ops_seckey_t *seckey;
|
||||
pgp_seckey_t *seckey;
|
||||
RSA *rsa;
|
||||
BN_CTX *ctx;
|
||||
__ops_output_t *output;
|
||||
__ops_memory_t *mem;
|
||||
pgp_output_t *output;
|
||||
pgp_memory_t *mem;
|
||||
|
||||
ctx = BN_CTX_new();
|
||||
__ops_keydata_init(keydata, OPS_PTAG_CT_SECRET_KEY);
|
||||
seckey = __ops_get_writable_seckey(keydata);
|
||||
pgp_keydata_init(keydata, PGP_PTAG_CT_SECRET_KEY);
|
||||
seckey = pgp_get_writable_seckey(keydata);
|
||||
|
||||
/* generate the key pair */
|
||||
|
||||
rsa = RSA_generate_key(numbits, e, NULL, NULL);
|
||||
|
||||
/* populate __ops key from ssl key */
|
||||
/* populate pgp key from ssl key */
|
||||
|
||||
seckey->pubkey.version = OPS_V4;
|
||||
seckey->pubkey.version = PGP_V4;
|
||||
seckey->pubkey.birthtime = time(NULL);
|
||||
seckey->pubkey.days_valid = 0;
|
||||
seckey->pubkey.alg = OPS_PKA_RSA;
|
||||
seckey->pubkey.alg = PGP_PKA_RSA;
|
||||
|
||||
seckey->pubkey.key.rsa.n = BN_dup(rsa->n);
|
||||
seckey->pubkey.key.rsa.e = BN_dup(rsa->e);
|
||||
|
||||
seckey->s2k_usage = OPS_S2KU_ENCRYPTED_AND_HASHED;
|
||||
seckey->s2k_specifier = OPS_S2KS_SALTED;
|
||||
/* seckey->s2k_specifier=OPS_S2KS_SIMPLE; */
|
||||
if ((seckey->hash_alg = __ops_str_to_hash_alg(hashalg)) == OPS_HASH_UNKNOWN) {
|
||||
seckey->hash_alg = OPS_HASH_SHA1;
|
||||
seckey->s2k_usage = PGP_S2KU_ENCRYPTED_AND_HASHED;
|
||||
seckey->s2k_specifier = PGP_S2KS_SALTED;
|
||||
/* seckey->s2k_specifier=PGP_S2KS_SIMPLE; */
|
||||
if ((seckey->hash_alg = pgp_str_to_hash_alg(hashalg)) == PGP_HASH_UNKNOWN) {
|
||||
seckey->hash_alg = PGP_HASH_SHA1;
|
||||
}
|
||||
seckey->alg = __ops_str_to_cipher(cipher);
|
||||
seckey->alg = pgp_str_to_cipher(cipher);
|
||||
seckey->octetc = 0;
|
||||
seckey->checksum = 0;
|
||||
|
||||
@ -734,33 +734,33 @@ rsa_generate_keypair(__ops_key_t *keydata,
|
||||
|
||||
RSA_free(rsa);
|
||||
|
||||
__ops_keyid(keydata->sigid, OPS_KEY_ID_SIZE, &keydata->key.seckey.pubkey, seckey->hash_alg);
|
||||
__ops_fingerprint(&keydata->sigfingerprint, &keydata->key.seckey.pubkey, seckey->hash_alg);
|
||||
pgp_keyid(keydata->sigid, PGP_KEY_ID_SIZE, &keydata->key.seckey.pubkey, seckey->hash_alg);
|
||||
pgp_fingerprint(&keydata->sigfingerprint, &keydata->key.seckey.pubkey, seckey->hash_alg);
|
||||
|
||||
/* Generate checksum */
|
||||
|
||||
output = NULL;
|
||||
mem = NULL;
|
||||
|
||||
__ops_setup_memory_write(&output, &mem, 128);
|
||||
pgp_setup_memory_write(&output, &mem, 128);
|
||||
|
||||
__ops_push_checksum_writer(output, seckey);
|
||||
pgp_push_checksum_writer(output, seckey);
|
||||
|
||||
switch (seckey->pubkey.alg) {
|
||||
case OPS_PKA_DSA:
|
||||
return __ops_write_mpi(output, seckey->key.dsa.x);
|
||||
case OPS_PKA_RSA:
|
||||
case OPS_PKA_RSA_ENCRYPT_ONLY:
|
||||
case OPS_PKA_RSA_SIGN_ONLY:
|
||||
if (!__ops_write_mpi(output, seckey->key.rsa.d) ||
|
||||
!__ops_write_mpi(output, seckey->key.rsa.p) ||
|
||||
!__ops_write_mpi(output, seckey->key.rsa.q) ||
|
||||
!__ops_write_mpi(output, seckey->key.rsa.u)) {
|
||||
case PGP_PKA_DSA:
|
||||
return pgp_write_mpi(output, seckey->key.dsa.x);
|
||||
case PGP_PKA_RSA:
|
||||
case PGP_PKA_RSA_ENCRYPT_ONLY:
|
||||
case PGP_PKA_RSA_SIGN_ONLY:
|
||||
if (!pgp_write_mpi(output, seckey->key.rsa.d) ||
|
||||
!pgp_write_mpi(output, seckey->key.rsa.p) ||
|
||||
!pgp_write_mpi(output, seckey->key.rsa.q) ||
|
||||
!pgp_write_mpi(output, seckey->key.rsa.u)) {
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
case OPS_PKA_ELGAMAL:
|
||||
return __ops_write_mpi(output, seckey->key.elgamal.x);
|
||||
case PGP_PKA_ELGAMAL:
|
||||
return pgp_write_mpi(output, seckey->key.elgamal.x);
|
||||
|
||||
default:
|
||||
(void) fprintf(stderr, "Bad seckey->pubkey.alg\n");
|
||||
@ -768,13 +768,13 @@ rsa_generate_keypair(__ops_key_t *keydata,
|
||||
}
|
||||
|
||||
/* close rather than pop, since its the only one on the stack */
|
||||
__ops_writer_close(output);
|
||||
__ops_teardown_memory_write(output, mem);
|
||||
pgp_writer_close(output);
|
||||
pgp_teardown_memory_write(output, mem);
|
||||
|
||||
/* should now have checksum in seckey struct */
|
||||
|
||||
/* test */
|
||||
if (__ops_get_debug_level(__FILE__)) {
|
||||
if (pgp_get_debug_level(__FILE__)) {
|
||||
test_seckey(seckey);
|
||||
}
|
||||
|
||||
@ -789,33 +789,33 @@ rsa_generate_keypair(__ops_key_t *keydata,
|
||||
\param userid User ID
|
||||
\return The new keypair or NULL
|
||||
|
||||
\note It is the caller's responsibility to call __ops_keydata_free(keydata)
|
||||
\note It is the caller's responsibility to call pgp_keydata_free(keydata)
|
||||
\sa rsa_generate_keypair()
|
||||
\sa __ops_keydata_free()
|
||||
\sa pgp_keydata_free()
|
||||
*/
|
||||
__ops_key_t *
|
||||
__ops_rsa_new_selfsign_key(const int numbits,
|
||||
pgp_key_t *
|
||||
pgp_rsa_new_selfsign_key(const int numbits,
|
||||
const unsigned long e,
|
||||
uint8_t *userid,
|
||||
const char *hashalg,
|
||||
const char *cipher)
|
||||
{
|
||||
__ops_key_t *keydata;
|
||||
pgp_key_t *keydata;
|
||||
|
||||
keydata = __ops_keydata_new();
|
||||
keydata = pgp_keydata_new();
|
||||
if (!rsa_generate_keypair(keydata, numbits, e, hashalg, cipher) ||
|
||||
!__ops_add_selfsigned_userid(keydata, userid)) {
|
||||
__ops_keydata_free(keydata);
|
||||
!pgp_add_selfsigned_userid(keydata, userid)) {
|
||||
pgp_keydata_free(keydata);
|
||||
return NULL;
|
||||
}
|
||||
return keydata;
|
||||
}
|
||||
|
||||
DSA_SIG *
|
||||
__ops_dsa_sign(uint8_t *hashbuf,
|
||||
pgp_dsa_sign(uint8_t *hashbuf,
|
||||
unsigned hashsize,
|
||||
const __ops_dsa_seckey_t *secdsa,
|
||||
const __ops_dsa_pubkey_t *pubdsa)
|
||||
const pgp_dsa_seckey_t *secdsa,
|
||||
const pgp_dsa_pubkey_t *pubdsa)
|
||||
{
|
||||
DSA_SIG *dsasig;
|
||||
DSA *odsa;
|
||||
@ -836,7 +836,7 @@ __ops_dsa_sign(uint8_t *hashbuf,
|
||||
}
|
||||
|
||||
int
|
||||
openssl_read_pem_seckey(const char *f, __ops_key_t *key, const char *type, int verbose)
|
||||
openssl_read_pem_seckey(const char *f, pgp_key_t *key, const char *type, int verbose)
|
||||
{
|
||||
FILE *fp;
|
||||
char prompt[BUFSIZ];
|
||||
@ -900,10 +900,10 @@ decide_k_bits(int p_bits)
|
||||
}
|
||||
|
||||
int
|
||||
__ops_elgamal_public_encrypt(uint8_t *g_to_k, uint8_t *encm,
|
||||
pgp_elgamal_public_encrypt(uint8_t *g_to_k, uint8_t *encm,
|
||||
const uint8_t *in,
|
||||
size_t size,
|
||||
const __ops_elgamal_pubkey_t *pubkey)
|
||||
const pgp_elgamal_pubkey_t *pubkey)
|
||||
{
|
||||
int ret = 0;
|
||||
int k_bits;
|
||||
@ -976,12 +976,12 @@ done:
|
||||
}
|
||||
|
||||
int
|
||||
__ops_elgamal_private_decrypt(uint8_t *out,
|
||||
pgp_elgamal_private_decrypt(uint8_t *out,
|
||||
const uint8_t *g_to_k,
|
||||
const uint8_t *in,
|
||||
size_t length,
|
||||
const __ops_elgamal_seckey_t *seckey,
|
||||
const __ops_elgamal_pubkey_t *pubkey)
|
||||
const pgp_elgamal_seckey_t *seckey,
|
||||
const pgp_elgamal_pubkey_t *pubkey)
|
||||
{
|
||||
BIGNUM *bndiv;
|
||||
BIGNUM *c1x;
|
||||
|
@ -26,16 +26,16 @@
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#ifndef OPS_SSH_H_
|
||||
#define OPS_SSH_H_
|
||||
#ifndef PGP_SSH_H_
|
||||
#define PGP_SSH_H_
|
||||
|
||||
#include "keyring.h"
|
||||
#include "types.h"
|
||||
|
||||
int __ops_ssh2pubkey(__ops_io_t *, const char *, __ops_key_t *, __ops_hash_alg_t);
|
||||
int __ops_ssh2seckey(__ops_io_t *, const char *, __ops_key_t *, __ops_pubkey_t *, __ops_hash_alg_t);
|
||||
int pgp_ssh2pubkey(pgp_io_t *, const char *, pgp_key_t *, pgp_hash_alg_t);
|
||||
int pgp_ssh2seckey(pgp_io_t *, const char *, pgp_key_t *, pgp_pubkey_t *, pgp_hash_alg_t);
|
||||
|
||||
int __ops_ssh2_readkeys(__ops_io_t *, __ops_keyring_t *, __ops_keyring_t *,
|
||||
int pgp_ssh2_readkeys(pgp_io_t *, pgp_keyring_t *, pgp_keyring_t *,
|
||||
const char *, const char *, unsigned);
|
||||
|
||||
#endif
|
||||
|
1230
crypto/external/bsd/netpgp/dist/src/lib/packet-parse.c
vendored
1230
crypto/external/bsd/netpgp/dist/src/lib/packet-parse.c
vendored
File diff suppressed because it is too large
Load Diff
@ -57,36 +57,36 @@
|
||||
#include "types.h"
|
||||
#include "packet.h"
|
||||
|
||||
/** __ops_region_t */
|
||||
typedef struct __ops_region_t {
|
||||
struct __ops_region_t *parent;
|
||||
/** pgp_region_t */
|
||||
typedef struct pgp_region_t {
|
||||
struct pgp_region_t *parent;
|
||||
unsigned length;
|
||||
unsigned readc; /* length read */
|
||||
unsigned last_read;
|
||||
/* length of last read, only valid in deepest child */
|
||||
unsigned indeterminate:1;
|
||||
} __ops_region_t;
|
||||
} pgp_region_t;
|
||||
|
||||
void __ops_init_subregion(__ops_region_t *, __ops_region_t *);
|
||||
void pgp_init_subregion(pgp_region_t *, pgp_region_t *);
|
||||
|
||||
/** __ops_cb_ret_t */
|
||||
/** pgp_cb_ret_t */
|
||||
typedef enum {
|
||||
OPS_RELEASE_MEMORY,
|
||||
OPS_KEEP_MEMORY,
|
||||
OPS_FINISHED
|
||||
} __ops_cb_ret_t;
|
||||
PGP_RELEASE_MEMORY,
|
||||
PGP_KEEP_MEMORY,
|
||||
PGP_FINISHED
|
||||
} pgp_cb_ret_t;
|
||||
|
||||
typedef struct __ops_cbdata_t __ops_cbdata_t;
|
||||
typedef struct pgp_cbdata_t pgp_cbdata_t;
|
||||
|
||||
typedef __ops_cb_ret_t __ops_cbfunc_t(const __ops_packet_t *,
|
||||
__ops_cbdata_t *);
|
||||
typedef pgp_cb_ret_t pgp_cbfunc_t(const pgp_packet_t *,
|
||||
pgp_cbdata_t *);
|
||||
|
||||
__ops_cb_ret_t
|
||||
get_passphrase_cb(const __ops_packet_t *, __ops_cbdata_t *);
|
||||
pgp_cb_ret_t
|
||||
get_passphrase_cb(const pgp_packet_t *, pgp_cbdata_t *);
|
||||
|
||||
typedef struct __ops_stream_t __ops_stream_t;
|
||||
typedef struct __ops_reader_t __ops_reader_t;
|
||||
typedef struct __ops_cryptinfo_t __ops_cryptinfo_t;
|
||||
typedef struct pgp_stream_t pgp_stream_t;
|
||||
typedef struct pgp_reader_t pgp_reader_t;
|
||||
typedef struct pgp_cryptinfo_t pgp_cryptinfo_t;
|
||||
|
||||
/*
|
||||
A reader MUST read at least one byte if it can, and should read up
|
||||
@ -107,63 +107,63 @@ typedef struct __ops_cryptinfo_t __ops_cryptinfo_t;
|
||||
to read more than INT_MAX in one go.
|
||||
|
||||
*/
|
||||
typedef int __ops_reader_func_t(void *, size_t, __ops_error_t **,
|
||||
__ops_reader_t *, __ops_cbdata_t *);
|
||||
typedef int pgp_reader_func_t(void *, size_t, pgp_error_t **,
|
||||
pgp_reader_t *, pgp_cbdata_t *);
|
||||
|
||||
typedef void __ops_reader_destroyer_t(__ops_reader_t *);
|
||||
typedef void pgp_reader_destroyer_t(pgp_reader_t *);
|
||||
|
||||
void __ops_stream_delete(__ops_stream_t *);
|
||||
__ops_error_t *__ops_stream_get_errors(__ops_stream_t *);
|
||||
__ops_crypt_t *__ops_get_decrypt(__ops_stream_t *);
|
||||
void pgp_stream_delete(pgp_stream_t *);
|
||||
pgp_error_t *pgp_stream_get_errors(pgp_stream_t *);
|
||||
pgp_crypt_t *pgp_get_decrypt(pgp_stream_t *);
|
||||
|
||||
void __ops_set_callback(__ops_stream_t *, __ops_cbfunc_t *, void *);
|
||||
void __ops_callback_push(__ops_stream_t *, __ops_cbfunc_t *, void *);
|
||||
void *__ops_callback_arg(__ops_cbdata_t *);
|
||||
void *__ops_callback_errors(__ops_cbdata_t *);
|
||||
void __ops_reader_set(__ops_stream_t *, __ops_reader_func_t *,
|
||||
__ops_reader_destroyer_t *, void *);
|
||||
void __ops_reader_push(__ops_stream_t *, __ops_reader_func_t *,
|
||||
__ops_reader_destroyer_t *, void *);
|
||||
void __ops_reader_pop(__ops_stream_t *);
|
||||
void pgp_set_callback(pgp_stream_t *, pgp_cbfunc_t *, void *);
|
||||
void pgp_callback_push(pgp_stream_t *, pgp_cbfunc_t *, void *);
|
||||
void *pgp_callback_arg(pgp_cbdata_t *);
|
||||
void *pgp_callback_errors(pgp_cbdata_t *);
|
||||
void pgp_reader_set(pgp_stream_t *, pgp_reader_func_t *,
|
||||
pgp_reader_destroyer_t *, void *);
|
||||
void pgp_reader_push(pgp_stream_t *, pgp_reader_func_t *,
|
||||
pgp_reader_destroyer_t *, void *);
|
||||
void pgp_reader_pop(pgp_stream_t *);
|
||||
|
||||
void *__ops_reader_get_arg(__ops_reader_t *);
|
||||
void *pgp_reader_get_arg(pgp_reader_t *);
|
||||
|
||||
__ops_cb_ret_t __ops_callback(const __ops_packet_t *,
|
||||
__ops_cbdata_t *);
|
||||
__ops_cb_ret_t __ops_stacked_callback(const __ops_packet_t *,
|
||||
__ops_cbdata_t *);
|
||||
__ops_reader_t *__ops_readinfo(__ops_stream_t *);
|
||||
pgp_cb_ret_t pgp_callback(const pgp_packet_t *,
|
||||
pgp_cbdata_t *);
|
||||
pgp_cb_ret_t pgp_stacked_callback(const pgp_packet_t *,
|
||||
pgp_cbdata_t *);
|
||||
pgp_reader_t *pgp_readinfo(pgp_stream_t *);
|
||||
|
||||
int __ops_parse(__ops_stream_t *, const int);
|
||||
int pgp_parse(pgp_stream_t *, const int);
|
||||
|
||||
/** Used to specify whether subpackets should be returned raw, parsed
|
||||
* or ignored. */
|
||||
typedef enum {
|
||||
OPS_PARSE_RAW, /* Callback Raw */
|
||||
OPS_PARSE_PARSED, /* Callback Parsed */
|
||||
OPS_PARSE_IGNORE /* Don't callback */
|
||||
} __ops_parse_type_t;
|
||||
PGP_PARSE_RAW, /* Callback Raw */
|
||||
PGP_PARSE_PARSED, /* Callback Parsed */
|
||||
PGP_PARSE_IGNORE /* Don't callback */
|
||||
} pgp_parse_type_t;
|
||||
|
||||
void __ops_parse_options(__ops_stream_t *, __ops_content_enum,
|
||||
__ops_parse_type_t);
|
||||
void pgp_parse_options(pgp_stream_t *, pgp_content_enum,
|
||||
pgp_parse_type_t);
|
||||
|
||||
unsigned __ops_limited_read(uint8_t *, size_t, __ops_region_t *,
|
||||
__ops_error_t **, __ops_reader_t *,
|
||||
__ops_cbdata_t *);
|
||||
unsigned __ops_stacked_limited_read(uint8_t *, unsigned,
|
||||
__ops_region_t *, __ops_error_t **,
|
||||
__ops_reader_t *, __ops_cbdata_t *);
|
||||
void __ops_parse_hash_init(__ops_stream_t *, __ops_hash_alg_t,
|
||||
unsigned pgp_limited_read(uint8_t *, size_t, pgp_region_t *,
|
||||
pgp_error_t **, pgp_reader_t *,
|
||||
pgp_cbdata_t *);
|
||||
unsigned pgp_stacked_limited_read(uint8_t *, unsigned,
|
||||
pgp_region_t *, pgp_error_t **,
|
||||
pgp_reader_t *, pgp_cbdata_t *);
|
||||
void pgp_parse_hash_init(pgp_stream_t *, pgp_hash_alg_t,
|
||||
const uint8_t *);
|
||||
void __ops_parse_hash_data(__ops_stream_t *, const void *, size_t);
|
||||
void __ops_parse_hash_finish(__ops_stream_t *);
|
||||
__ops_hash_t *__ops_parse_hash_find(__ops_stream_t *, const uint8_t *);
|
||||
void pgp_parse_hash_data(pgp_stream_t *, const void *, size_t);
|
||||
void pgp_parse_hash_finish(pgp_stream_t *);
|
||||
pgp_hash_t *pgp_parse_hash_find(pgp_stream_t *, const uint8_t *);
|
||||
|
||||
__ops_reader_func_t __ops_stacked_read;
|
||||
pgp_reader_func_t pgp_stacked_read;
|
||||
|
||||
int __ops_decompress(__ops_region_t *, __ops_stream_t *,
|
||||
__ops_compression_type_t);
|
||||
unsigned __ops_writez(__ops_output_t *, const uint8_t *,
|
||||
int pgp_decompress(pgp_region_t *, pgp_stream_t *,
|
||||
pgp_compression_type_t);
|
||||
unsigned pgp_writez(pgp_output_t *, const uint8_t *,
|
||||
const unsigned);
|
||||
|
||||
#endif /* PACKET_PARSE_H_ */
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -60,7 +60,7 @@
|
||||
|
||||
#if defined(__NetBSD__)
|
||||
__COPYRIGHT("@(#) Copyright (c) 2009 The NetBSD Foundation, Inc. All rights reserved.");
|
||||
__RCSID("$NetBSD: packet-show.c,v 1.18 2010/11/04 06:45:28 agc Exp $");
|
||||
__RCSID("$NetBSD: packet-show.c,v 1.19 2010/11/07 08:39:59 agc Exp $");
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
@ -76,109 +76,109 @@ __RCSID("$NetBSD: packet-show.c,v 1.18 2010/11/04 06:45:28 agc Exp $");
|
||||
* Arrays of value->text maps
|
||||
*/
|
||||
|
||||
static __ops_map_t packet_tag_map[] =
|
||||
static pgp_map_t packet_tag_map[] =
|
||||
{
|
||||
{OPS_PTAG_CT_RESERVED, "Reserved"},
|
||||
{OPS_PTAG_CT_PK_SESSION_KEY, "Public-Key Encrypted Session Key"},
|
||||
{OPS_PTAG_CT_SIGNATURE, "Signature"},
|
||||
{OPS_PTAG_CT_SK_SESSION_KEY, "Symmetric-Key Encrypted Session Key"},
|
||||
{OPS_PTAG_CT_1_PASS_SIG, "One-Pass Signature"},
|
||||
{OPS_PTAG_CT_SECRET_KEY, "Secret Key"},
|
||||
{OPS_PTAG_CT_PUBLIC_KEY, "Public Key"},
|
||||
{OPS_PTAG_CT_SECRET_SUBKEY, "Secret Subkey"},
|
||||
{OPS_PTAG_CT_COMPRESSED, "Compressed Data"},
|
||||
{OPS_PTAG_CT_SE_DATA, "Symmetrically Encrypted Data"},
|
||||
{OPS_PTAG_CT_MARKER, "Marker"},
|
||||
{OPS_PTAG_CT_LITDATA, "Literal Data"},
|
||||
{OPS_PTAG_CT_TRUST, "Trust"},
|
||||
{OPS_PTAG_CT_USER_ID, "User ID"},
|
||||
{OPS_PTAG_CT_PUBLIC_SUBKEY, "Public Subkey"},
|
||||
{OPS_PTAG_CT_RESERVED2, "reserved2"},
|
||||
{OPS_PTAG_CT_RESERVED3, "reserved3"},
|
||||
{OPS_PTAG_CT_USER_ATTR, "User Attribute"},
|
||||
{OPS_PTAG_CT_SE_IP_DATA,
|
||||
{PGP_PTAG_CT_RESERVED, "Reserved"},
|
||||
{PGP_PTAG_CT_PK_SESSION_KEY, "Public-Key Encrypted Session Key"},
|
||||
{PGP_PTAG_CT_SIGNATURE, "Signature"},
|
||||
{PGP_PTAG_CT_SK_SESSION_KEY, "Symmetric-Key Encrypted Session Key"},
|
||||
{PGP_PTAG_CT_1_PASS_SIG, "One-Pass Signature"},
|
||||
{PGP_PTAG_CT_SECRET_KEY, "Secret Key"},
|
||||
{PGP_PTAG_CT_PUBLIC_KEY, "Public Key"},
|
||||
{PGP_PTAG_CT_SECRET_SUBKEY, "Secret Subkey"},
|
||||
{PGP_PTAG_CT_COMPRESSED, "Compressed Data"},
|
||||
{PGP_PTAG_CT_SE_DATA, "Symmetrically Encrypted Data"},
|
||||
{PGP_PTAG_CT_MARKER, "Marker"},
|
||||
{PGP_PTAG_CT_LITDATA, "Literal Data"},
|
||||
{PGP_PTAG_CT_TRUST, "Trust"},
|
||||
{PGP_PTAG_CT_USER_ID, "User ID"},
|
||||
{PGP_PTAG_CT_PUBLIC_SUBKEY, "Public Subkey"},
|
||||
{PGP_PTAG_CT_RESERVED2, "reserved2"},
|
||||
{PGP_PTAG_CT_RESERVED3, "reserved3"},
|
||||
{PGP_PTAG_CT_USER_ATTR, "User Attribute"},
|
||||
{PGP_PTAG_CT_SE_IP_DATA,
|
||||
"Symmetric Encrypted and Integrity Protected Data"},
|
||||
{OPS_PTAG_CT_MDC, "Modification Detection Code"},
|
||||
{OPS_PARSER_PTAG, "OPS_PARSER_PTAG"},
|
||||
{OPS_PTAG_RAW_SS, "OPS_PTAG_RAW_SS"},
|
||||
{OPS_PTAG_SS_ALL, "OPS_PTAG_SS_ALL"},
|
||||
{OPS_PARSER_PACKET_END, "OPS_PARSER_PACKET_END"},
|
||||
{OPS_PTAG_SIG_SUBPKT_BASE, "OPS_PTAG_SIG_SUBPKT_BASE"},
|
||||
{OPS_PTAG_SS_CREATION_TIME, "SS: Signature Creation Time"},
|
||||
{OPS_PTAG_SS_EXPIRATION_TIME, "SS: Signature Expiration Time"},
|
||||
{OPS_PTAG_SS_EXPORT_CERT, "SS: Exportable Certification"},
|
||||
{OPS_PTAG_SS_TRUST, "SS: Trust Signature"},
|
||||
{OPS_PTAG_SS_REGEXP, "SS: Regular Expression"},
|
||||
{OPS_PTAG_SS_REVOCABLE, "SS: Revocable"},
|
||||
{OPS_PTAG_SS_KEY_EXPIRY, "SS: Key Expiration Time"},
|
||||
{OPS_PTAG_SS_RESERVED, "SS: Reserved"},
|
||||
{OPS_PTAG_SS_PREFERRED_SKA, "SS: Preferred Secret Key Algorithm"},
|
||||
{OPS_PTAG_SS_REVOCATION_KEY, "SS: Revocation Key"},
|
||||
{OPS_PTAG_SS_ISSUER_KEY_ID, "SS: Issuer Key Id"},
|
||||
{OPS_PTAG_SS_NOTATION_DATA, "SS: Notation Data"},
|
||||
{OPS_PTAG_SS_PREFERRED_HASH, "SS: Preferred Hash Algorithm"},
|
||||
{OPS_PTAG_SS_PREF_COMPRESS, "SS: Preferred Compression Algorithm"},
|
||||
{OPS_PTAG_SS_KEYSERV_PREFS, "SS: Key Server Preferences"},
|
||||
{OPS_PTAG_SS_PREF_KEYSERV, "SS: Preferred Key Server"},
|
||||
{OPS_PTAG_SS_PRIMARY_USER_ID, "SS: Primary User ID"},
|
||||
{OPS_PTAG_SS_POLICY_URI, "SS: Policy URI"},
|
||||
{OPS_PTAG_SS_KEY_FLAGS, "SS: Key Flags"},
|
||||
{OPS_PTAG_SS_SIGNERS_USER_ID, "SS: Signer's User ID"},
|
||||
{OPS_PTAG_SS_REVOCATION_REASON, "SS: Reason for Revocation"},
|
||||
{OPS_PTAG_SS_FEATURES, "SS: Features"},
|
||||
{OPS_PTAG_SS_SIGNATURE_TARGET, "SS: Signature Target"},
|
||||
{OPS_PTAG_SS_EMBEDDED_SIGNATURE, "SS: Embedded Signature"},
|
||||
{PGP_PTAG_CT_MDC, "Modification Detection Code"},
|
||||
{PGP_PARSER_PTAG, "PGP_PARSER_PTAG"},
|
||||
{PGP_PTAG_RAW_SS, "PGP_PTAG_RAW_SS"},
|
||||
{PGP_PTAG_SS_ALL, "PGP_PTAG_SS_ALL"},
|
||||
{PGP_PARSER_PACKET_END, "PGP_PARSER_PACKET_END"},
|
||||
{PGP_PTAG_SIG_SUBPKT_BASE, "PGP_PTAG_SIG_SUBPKT_BASE"},
|
||||
{PGP_PTAG_SS_CREATION_TIME, "SS: Signature Creation Time"},
|
||||
{PGP_PTAG_SS_EXPIRATION_TIME, "SS: Signature Expiration Time"},
|
||||
{PGP_PTAG_SS_EXPORT_CERT, "SS: Exportable Certification"},
|
||||
{PGP_PTAG_SS_TRUST, "SS: Trust Signature"},
|
||||
{PGP_PTAG_SS_REGEXP, "SS: Regular Expression"},
|
||||
{PGP_PTAG_SS_REVOCABLE, "SS: Revocable"},
|
||||
{PGP_PTAG_SS_KEY_EXPIRY, "SS: Key Expiration Time"},
|
||||
{PGP_PTAG_SS_RESERVED, "SS: Reserved"},
|
||||
{PGP_PTAG_SS_PREFERRED_SKA, "SS: Preferred Secret Key Algorithm"},
|
||||
{PGP_PTAG_SS_REVOCATION_KEY, "SS: Revocation Key"},
|
||||
{PGP_PTAG_SS_ISSUER_KEY_ID, "SS: Issuer Key Id"},
|
||||
{PGP_PTAG_SS_NOTATION_DATA, "SS: Notation Data"},
|
||||
{PGP_PTAG_SS_PREFERRED_HASH, "SS: Preferred Hash Algorithm"},
|
||||
{PGP_PTAG_SS_PREF_COMPRESS, "SS: Preferred Compression Algorithm"},
|
||||
{PGP_PTAG_SS_KEYSERV_PREFS, "SS: Key Server Preferences"},
|
||||
{PGP_PTAG_SS_PREF_KEYSERV, "SS: Preferred Key Server"},
|
||||
{PGP_PTAG_SS_PRIMARY_USER_ID, "SS: Primary User ID"},
|
||||
{PGP_PTAG_SS_POLICY_URI, "SS: Policy URI"},
|
||||
{PGP_PTAG_SS_KEY_FLAGS, "SS: Key Flags"},
|
||||
{PGP_PTAG_SS_SIGNERS_USER_ID, "SS: Signer's User ID"},
|
||||
{PGP_PTAG_SS_REVOCATION_REASON, "SS: Reason for Revocation"},
|
||||
{PGP_PTAG_SS_FEATURES, "SS: Features"},
|
||||
{PGP_PTAG_SS_SIGNATURE_TARGET, "SS: Signature Target"},
|
||||
{PGP_PTAG_SS_EMBEDDED_SIGNATURE, "SS: Embedded Signature"},
|
||||
|
||||
{OPS_PTAG_CT_LITDATA_HEADER, "CT: Literal Data Header"},
|
||||
{OPS_PTAG_CT_LITDATA_BODY, "CT: Literal Data Body"},
|
||||
{OPS_PTAG_CT_SIGNATURE_HEADER, "CT: Signature Header"},
|
||||
{OPS_PTAG_CT_SIGNATURE_FOOTER, "CT: Signature Footer"},
|
||||
{OPS_PTAG_CT_ARMOUR_HEADER, "CT: Armour Header"},
|
||||
{OPS_PTAG_CT_ARMOUR_TRAILER, "CT: Armour Trailer"},
|
||||
{OPS_PTAG_CT_SIGNED_CLEARTEXT_HEADER, "CT: Signed Cleartext Header"},
|
||||
{OPS_PTAG_CT_SIGNED_CLEARTEXT_BODY, "CT: Signed Cleartext Body"},
|
||||
{OPS_PTAG_CT_SIGNED_CLEARTEXT_TRAILER, "CT: Signed Cleartext Trailer"},
|
||||
{OPS_PTAG_CT_UNARMOURED_TEXT, "CT: Unarmoured Text"},
|
||||
{OPS_PTAG_CT_ENCRYPTED_SECRET_KEY, "CT: Encrypted Secret Key"},
|
||||
{OPS_PTAG_CT_SE_DATA_HEADER, "CT: Sym Encrypted Data Header"},
|
||||
{OPS_PTAG_CT_SE_DATA_BODY, "CT: Sym Encrypted Data Body"},
|
||||
{OPS_PTAG_CT_SE_IP_DATA_HEADER, "CT: Sym Encrypted IP Data Header"},
|
||||
{OPS_PTAG_CT_SE_IP_DATA_BODY, "CT: Sym Encrypted IP Data Body"},
|
||||
{OPS_PTAG_CT_ENCRYPTED_PK_SESSION_KEY, "CT: Encrypted PK Session Key"},
|
||||
{OPS_GET_PASSPHRASE, "CMD: Get Secret Key Passphrase"},
|
||||
{OPS_GET_SECKEY, "CMD: Get Secret Key"},
|
||||
{OPS_PARSER_ERROR, "OPS_PARSER_ERROR"},
|
||||
{OPS_PARSER_ERRCODE, "OPS_PARSER_ERRCODE"},
|
||||
{PGP_PTAG_CT_LITDATA_HEADER, "CT: Literal Data Header"},
|
||||
{PGP_PTAG_CT_LITDATA_BODY, "CT: Literal Data Body"},
|
||||
{PGP_PTAG_CT_SIGNATURE_HEADER, "CT: Signature Header"},
|
||||
{PGP_PTAG_CT_SIGNATURE_FOOTER, "CT: Signature Footer"},
|
||||
{PGP_PTAG_CT_ARMOUR_HEADER, "CT: Armour Header"},
|
||||
{PGP_PTAG_CT_ARMOUR_TRAILER, "CT: Armour Trailer"},
|
||||
{PGP_PTAG_CT_SIGNED_CLEARTEXT_HEADER, "CT: Signed Cleartext Header"},
|
||||
{PGP_PTAG_CT_SIGNED_CLEARTEXT_BODY, "CT: Signed Cleartext Body"},
|
||||
{PGP_PTAG_CT_SIGNED_CLEARTEXT_TRAILER, "CT: Signed Cleartext Trailer"},
|
||||
{PGP_PTAG_CT_UNARMOURED_TEXT, "CT: Unarmoured Text"},
|
||||
{PGP_PTAG_CT_ENCRYPTED_SECRET_KEY, "CT: Encrypted Secret Key"},
|
||||
{PGP_PTAG_CT_SE_DATA_HEADER, "CT: Sym Encrypted Data Header"},
|
||||
{PGP_PTAG_CT_SE_DATA_BODY, "CT: Sym Encrypted Data Body"},
|
||||
{PGP_PTAG_CT_SE_IP_DATA_HEADER, "CT: Sym Encrypted IP Data Header"},
|
||||
{PGP_PTAG_CT_SE_IP_DATA_BODY, "CT: Sym Encrypted IP Data Body"},
|
||||
{PGP_PTAG_CT_ENCRYPTED_PK_SESSION_KEY, "CT: Encrypted PK Session Key"},
|
||||
{PGP_GET_PASSPHRASE, "CMD: Get Secret Key Passphrase"},
|
||||
{PGP_GET_SECKEY, "CMD: Get Secret Key"},
|
||||
{PGP_PARSER_ERROR, "PGP_PARSER_ERROR"},
|
||||
{PGP_PARSER_ERRCODE, "PGP_PARSER_ERRCODE"},
|
||||
|
||||
{0x00, NULL}, /* this is the end-of-array marker */
|
||||
};
|
||||
|
||||
static __ops_map_t ss_type_map[] =
|
||||
static pgp_map_t ss_type_map[] =
|
||||
{
|
||||
{OPS_PTAG_SS_CREATION_TIME, "Signature Creation Time"},
|
||||
{OPS_PTAG_SS_EXPIRATION_TIME, "Signature Expiration Time"},
|
||||
{OPS_PTAG_SS_TRUST, "Trust Signature"},
|
||||
{OPS_PTAG_SS_REGEXP, "Regular Expression"},
|
||||
{OPS_PTAG_SS_REVOCABLE, "Revocable"},
|
||||
{OPS_PTAG_SS_KEY_EXPIRY, "Key Expiration Time"},
|
||||
{OPS_PTAG_SS_PREFERRED_SKA, "Preferred Symmetric Algorithms"},
|
||||
{OPS_PTAG_SS_REVOCATION_KEY, "Revocation Key"},
|
||||
{OPS_PTAG_SS_ISSUER_KEY_ID, "Issuer key ID"},
|
||||
{OPS_PTAG_SS_NOTATION_DATA, "Notation Data"},
|
||||
{OPS_PTAG_SS_PREFERRED_HASH, "Preferred Hash Algorithms"},
|
||||
{OPS_PTAG_SS_PREF_COMPRESS, "Preferred Compression Algorithms"},
|
||||
{OPS_PTAG_SS_KEYSERV_PREFS, "Key Server Preferences"},
|
||||
{OPS_PTAG_SS_PREF_KEYSERV, "Preferred Key Server"},
|
||||
{OPS_PTAG_SS_PRIMARY_USER_ID, "Primary User ID"},
|
||||
{OPS_PTAG_SS_POLICY_URI, "Policy URI"},
|
||||
{OPS_PTAG_SS_KEY_FLAGS, "Key Flags"},
|
||||
{OPS_PTAG_SS_REVOCATION_REASON, "Reason for Revocation"},
|
||||
{OPS_PTAG_SS_FEATURES, "Features"},
|
||||
{PGP_PTAG_SS_CREATION_TIME, "Signature Creation Time"},
|
||||
{PGP_PTAG_SS_EXPIRATION_TIME, "Signature Expiration Time"},
|
||||
{PGP_PTAG_SS_TRUST, "Trust Signature"},
|
||||
{PGP_PTAG_SS_REGEXP, "Regular Expression"},
|
||||
{PGP_PTAG_SS_REVOCABLE, "Revocable"},
|
||||
{PGP_PTAG_SS_KEY_EXPIRY, "Key Expiration Time"},
|
||||
{PGP_PTAG_SS_PREFERRED_SKA, "Preferred Symmetric Algorithms"},
|
||||
{PGP_PTAG_SS_REVOCATION_KEY, "Revocation Key"},
|
||||
{PGP_PTAG_SS_ISSUER_KEY_ID, "Issuer key ID"},
|
||||
{PGP_PTAG_SS_NOTATION_DATA, "Notation Data"},
|
||||
{PGP_PTAG_SS_PREFERRED_HASH, "Preferred Hash Algorithms"},
|
||||
{PGP_PTAG_SS_PREF_COMPRESS, "Preferred Compression Algorithms"},
|
||||
{PGP_PTAG_SS_KEYSERV_PREFS, "Key Server Preferences"},
|
||||
{PGP_PTAG_SS_PREF_KEYSERV, "Preferred Key Server"},
|
||||
{PGP_PTAG_SS_PRIMARY_USER_ID, "Primary User ID"},
|
||||
{PGP_PTAG_SS_POLICY_URI, "Policy URI"},
|
||||
{PGP_PTAG_SS_KEY_FLAGS, "Key Flags"},
|
||||
{PGP_PTAG_SS_REVOCATION_REASON, "Reason for Revocation"},
|
||||
{PGP_PTAG_SS_FEATURES, "Features"},
|
||||
{0x00, NULL}, /* this is the end-of-array marker */
|
||||
};
|
||||
|
||||
|
||||
static __ops_map_t ss_rr_code_map[] =
|
||||
static pgp_map_t ss_rr_code_map[] =
|
||||
{
|
||||
{0x00, "No reason specified"},
|
||||
{0x01, "Key is superseded"},
|
||||
@ -188,112 +188,112 @@ static __ops_map_t ss_rr_code_map[] =
|
||||
{0x00, NULL}, /* this is the end-of-array marker */
|
||||
};
|
||||
|
||||
static __ops_map_t sig_type_map[] =
|
||||
static pgp_map_t sig_type_map[] =
|
||||
{
|
||||
{OPS_SIG_BINARY, "Signature of a binary document"},
|
||||
{OPS_SIG_TEXT, "Signature of a canonical text document"},
|
||||
{OPS_SIG_STANDALONE, "Standalone signature"},
|
||||
{OPS_CERT_GENERIC, "Generic certification of a User ID and Public Key packet"},
|
||||
{OPS_CERT_PERSONA, "Personal certification of a User ID and Public Key packet"},
|
||||
{OPS_CERT_CASUAL, "Casual certification of a User ID and Public Key packet"},
|
||||
{OPS_CERT_POSITIVE, "Positive certification of a User ID and Public Key packet"},
|
||||
{OPS_SIG_SUBKEY, "Subkey Binding Signature"},
|
||||
{OPS_SIG_PRIMARY, "Primary Key Binding Signature"},
|
||||
{OPS_SIG_DIRECT, "Signature directly on a key"},
|
||||
{OPS_SIG_REV_KEY, "Key revocation signature"},
|
||||
{OPS_SIG_REV_SUBKEY, "Subkey revocation signature"},
|
||||
{OPS_SIG_REV_CERT, "Certification revocation signature"},
|
||||
{OPS_SIG_TIMESTAMP, "Timestamp signature"},
|
||||
{OPS_SIG_3RD_PARTY, "Third-Party Confirmation signature"},
|
||||
{PGP_SIG_BINARY, "Signature of a binary document"},
|
||||
{PGP_SIG_TEXT, "Signature of a canonical text document"},
|
||||
{PGP_SIG_STANDALONE, "Standalone signature"},
|
||||
{PGP_CERT_GENERIC, "Generic certification of a User ID and Public Key packet"},
|
||||
{PGP_CERT_PERSONA, "Personal certification of a User ID and Public Key packet"},
|
||||
{PGP_CERT_CASUAL, "Casual certification of a User ID and Public Key packet"},
|
||||
{PGP_CERT_POSITIVE, "Positive certification of a User ID and Public Key packet"},
|
||||
{PGP_SIG_SUBKEY, "Subkey Binding Signature"},
|
||||
{PGP_SIG_PRIMARY, "Primary Key Binding Signature"},
|
||||
{PGP_SIG_DIRECT, "Signature directly on a key"},
|
||||
{PGP_SIG_REV_KEY, "Key revocation signature"},
|
||||
{PGP_SIG_REV_SUBKEY, "Subkey revocation signature"},
|
||||
{PGP_SIG_REV_CERT, "Certification revocation signature"},
|
||||
{PGP_SIG_TIMESTAMP, "Timestamp signature"},
|
||||
{PGP_SIG_3RD_PARTY, "Third-Party Confirmation signature"},
|
||||
{0x00, NULL}, /* this is the end-of-array marker */
|
||||
};
|
||||
|
||||
static __ops_map_t pubkey_alg_map[] =
|
||||
static pgp_map_t pubkey_alg_map[] =
|
||||
{
|
||||
{OPS_PKA_RSA, "RSA (Encrypt or Sign)"},
|
||||
{OPS_PKA_RSA_ENCRYPT_ONLY, "RSA Encrypt-Only"},
|
||||
{OPS_PKA_RSA_SIGN_ONLY, "RSA Sign-Only"},
|
||||
{OPS_PKA_ELGAMAL, "Elgamal (Encrypt-Only)"},
|
||||
{OPS_PKA_DSA, "DSA"},
|
||||
{OPS_PKA_RESERVED_ELLIPTIC_CURVE, "Reserved for Elliptic Curve"},
|
||||
{OPS_PKA_RESERVED_ECDSA, "Reserved for ECDSA"},
|
||||
{OPS_PKA_ELGAMAL_ENCRYPT_OR_SIGN, "Reserved (formerly Elgamal Encrypt or Sign"},
|
||||
{OPS_PKA_RESERVED_DH, "Reserved for Diffie-Hellman (X9.42)"},
|
||||
{OPS_PKA_PRIVATE00, "Private/Experimental"},
|
||||
{OPS_PKA_PRIVATE01, "Private/Experimental"},
|
||||
{OPS_PKA_PRIVATE02, "Private/Experimental"},
|
||||
{OPS_PKA_PRIVATE03, "Private/Experimental"},
|
||||
{OPS_PKA_PRIVATE04, "Private/Experimental"},
|
||||
{OPS_PKA_PRIVATE05, "Private/Experimental"},
|
||||
{OPS_PKA_PRIVATE06, "Private/Experimental"},
|
||||
{OPS_PKA_PRIVATE07, "Private/Experimental"},
|
||||
{OPS_PKA_PRIVATE08, "Private/Experimental"},
|
||||
{OPS_PKA_PRIVATE09, "Private/Experimental"},
|
||||
{OPS_PKA_PRIVATE10, "Private/Experimental"},
|
||||
{PGP_PKA_RSA, "RSA (Encrypt or Sign)"},
|
||||
{PGP_PKA_RSA_ENCRYPT_ONLY, "RSA Encrypt-Only"},
|
||||
{PGP_PKA_RSA_SIGN_ONLY, "RSA Sign-Only"},
|
||||
{PGP_PKA_ELGAMAL, "Elgamal (Encrypt-Only)"},
|
||||
{PGP_PKA_DSA, "DSA"},
|
||||
{PGP_PKA_RESERVED_ELLIPTIC_CURVE, "Reserved for Elliptic Curve"},
|
||||
{PGP_PKA_RESERVED_ECDSA, "Reserved for ECDSA"},
|
||||
{PGP_PKA_ELGAMAL_ENCRYPT_OR_SIGN, "Reserved (formerly Elgamal Encrypt or Sign"},
|
||||
{PGP_PKA_RESERVED_DH, "Reserved for Diffie-Hellman (X9.42)"},
|
||||
{PGP_PKA_PRIVATE00, "Private/Experimental"},
|
||||
{PGP_PKA_PRIVATE01, "Private/Experimental"},
|
||||
{PGP_PKA_PRIVATE02, "Private/Experimental"},
|
||||
{PGP_PKA_PRIVATE03, "Private/Experimental"},
|
||||
{PGP_PKA_PRIVATE04, "Private/Experimental"},
|
||||
{PGP_PKA_PRIVATE05, "Private/Experimental"},
|
||||
{PGP_PKA_PRIVATE06, "Private/Experimental"},
|
||||
{PGP_PKA_PRIVATE07, "Private/Experimental"},
|
||||
{PGP_PKA_PRIVATE08, "Private/Experimental"},
|
||||
{PGP_PKA_PRIVATE09, "Private/Experimental"},
|
||||
{PGP_PKA_PRIVATE10, "Private/Experimental"},
|
||||
{0x00, NULL}, /* this is the end-of-array marker */
|
||||
};
|
||||
|
||||
static __ops_map_t symm_alg_map[] =
|
||||
static pgp_map_t symm_alg_map[] =
|
||||
{
|
||||
{OPS_SA_PLAINTEXT, "Plaintext or unencrypted data"},
|
||||
{OPS_SA_IDEA, "IDEA"},
|
||||
{OPS_SA_TRIPLEDES, "TripleDES"},
|
||||
{OPS_SA_CAST5, "CAST5"},
|
||||
{OPS_SA_BLOWFISH, "Blowfish"},
|
||||
{OPS_SA_AES_128, "AES (128-bit key)"},
|
||||
{OPS_SA_AES_192, "AES (192-bit key)"},
|
||||
{OPS_SA_AES_256, "AES (256-bit key)"},
|
||||
{OPS_SA_TWOFISH, "Twofish(256-bit key)"},
|
||||
{OPS_SA_CAMELLIA_128, "Camellia (128-bit key)"},
|
||||
{OPS_SA_CAMELLIA_192, "Camellia (192-bit key)"},
|
||||
{OPS_SA_CAMELLIA_256, "Camellia (256-bit key)"},
|
||||
{PGP_SA_PLAINTEXT, "Plaintext or unencrypted data"},
|
||||
{PGP_SA_IDEA, "IDEA"},
|
||||
{PGP_SA_TRIPLEDES, "TripleDES"},
|
||||
{PGP_SA_CAST5, "CAST5"},
|
||||
{PGP_SA_BLOWFISH, "Blowfish"},
|
||||
{PGP_SA_AES_128, "AES (128-bit key)"},
|
||||
{PGP_SA_AES_192, "AES (192-bit key)"},
|
||||
{PGP_SA_AES_256, "AES (256-bit key)"},
|
||||
{PGP_SA_TWOFISH, "Twofish(256-bit key)"},
|
||||
{PGP_SA_CAMELLIA_128, "Camellia (128-bit key)"},
|
||||
{PGP_SA_CAMELLIA_192, "Camellia (192-bit key)"},
|
||||
{PGP_SA_CAMELLIA_256, "Camellia (256-bit key)"},
|
||||
{0x00, NULL}, /* this is the end-of-array marker */
|
||||
};
|
||||
|
||||
static __ops_map_t hash_alg_map[] =
|
||||
static pgp_map_t hash_alg_map[] =
|
||||
{
|
||||
{OPS_HASH_MD5, "MD5"},
|
||||
{OPS_HASH_SHA1, "SHA1"},
|
||||
{OPS_HASH_RIPEMD, "RIPEMD160"},
|
||||
{OPS_HASH_SHA256, "SHA256"},
|
||||
{OPS_HASH_SHA384, "SHA384"},
|
||||
{OPS_HASH_SHA512, "SHA512"},
|
||||
{OPS_HASH_SHA224, "SHA224"},
|
||||
{PGP_HASH_MD5, "MD5"},
|
||||
{PGP_HASH_SHA1, "SHA1"},
|
||||
{PGP_HASH_RIPEMD, "RIPEMD160"},
|
||||
{PGP_HASH_SHA256, "SHA256"},
|
||||
{PGP_HASH_SHA384, "SHA384"},
|
||||
{PGP_HASH_SHA512, "SHA512"},
|
||||
{PGP_HASH_SHA224, "SHA224"},
|
||||
{0x00, NULL}, /* this is the end-of-array marker */
|
||||
};
|
||||
|
||||
static __ops_map_t compression_alg_map[] =
|
||||
static pgp_map_t compression_alg_map[] =
|
||||
{
|
||||
{OPS_C_NONE, "Uncompressed"},
|
||||
{OPS_C_ZIP, "ZIP(RFC1951)"},
|
||||
{OPS_C_ZLIB, "ZLIB(RFC1950)"},
|
||||
{OPS_C_BZIP2, "Bzip2(BZ2)"},
|
||||
{PGP_C_NONE, "Uncompressed"},
|
||||
{PGP_C_ZIP, "ZIP(RFC1951)"},
|
||||
{PGP_C_ZLIB, "ZLIB(RFC1950)"},
|
||||
{PGP_C_BZIP2, "Bzip2(BZ2)"},
|
||||
{0x00, NULL}, /* this is the end-of-array marker */
|
||||
};
|
||||
|
||||
static __ops_bit_map_t ss_notation_map_byte0[] =
|
||||
static pgp_bit_map_t ss_notation_map_byte0[] =
|
||||
{
|
||||
{0x80, "Human-readable"},
|
||||
{0x00, NULL},
|
||||
};
|
||||
|
||||
static __ops_bit_map_t *ss_notation_map[] =
|
||||
static pgp_bit_map_t *ss_notation_map[] =
|
||||
{
|
||||
ss_notation_map_byte0,
|
||||
};
|
||||
|
||||
static __ops_bit_map_t ss_feature_map_byte0[] =
|
||||
static pgp_bit_map_t ss_feature_map_byte0[] =
|
||||
{
|
||||
{0x01, "Modification Detection"},
|
||||
{0x00, NULL},
|
||||
};
|
||||
|
||||
static __ops_bit_map_t *ss_feature_map[] =
|
||||
static pgp_bit_map_t *ss_feature_map[] =
|
||||
{
|
||||
ss_feature_map_byte0,
|
||||
};
|
||||
|
||||
static __ops_bit_map_t ss_key_flags_map[] =
|
||||
static pgp_bit_map_t ss_key_flags_map[] =
|
||||
{
|
||||
{0x01, "May be used to certify other keys"},
|
||||
{0x02, "May be used to sign data"},
|
||||
@ -304,7 +304,7 @@ static __ops_bit_map_t ss_key_flags_map[] =
|
||||
{0x00, NULL},
|
||||
};
|
||||
|
||||
static __ops_bit_map_t ss_key_server_prefs_map[] =
|
||||
static pgp_bit_map_t ss_key_server_prefs_map[] =
|
||||
{
|
||||
{0x80, "Key holder requests that this key only be modified or updated by the key holder or an administrator of the key server"},
|
||||
{0x00, NULL},
|
||||
@ -315,7 +315,7 @@ static __ops_bit_map_t ss_key_server_prefs_map[] =
|
||||
*/
|
||||
|
||||
static void
|
||||
list_init(__ops_list_t *list)
|
||||
list_init(pgp_list_t *list)
|
||||
{
|
||||
list->size = 0;
|
||||
list->used = 0;
|
||||
@ -323,7 +323,7 @@ list_init(__ops_list_t *list)
|
||||
}
|
||||
|
||||
static void
|
||||
list_free_strings(__ops_list_t *list)
|
||||
list_free_strings(pgp_list_t *list)
|
||||
{
|
||||
unsigned i;
|
||||
|
||||
@ -334,7 +334,7 @@ list_free_strings(__ops_list_t *list)
|
||||
}
|
||||
|
||||
static void
|
||||
list_free(__ops_list_t *list)
|
||||
list_free(pgp_list_t *list)
|
||||
{
|
||||
if (list->strings)
|
||||
free(list->strings);
|
||||
@ -342,7 +342,7 @@ list_free(__ops_list_t *list)
|
||||
}
|
||||
|
||||
static unsigned
|
||||
list_resize(__ops_list_t *list)
|
||||
list_resize(pgp_list_t *list)
|
||||
{
|
||||
/*
|
||||
* We only resize in one direction - upwards. Algorithm used : double
|
||||
@ -363,7 +363,7 @@ list_resize(__ops_list_t *list)
|
||||
}
|
||||
|
||||
static unsigned
|
||||
add_str(__ops_list_t *list, const char *str)
|
||||
add_str(pgp_list_t *list, const char *str)
|
||||
{
|
||||
if (list->size == list->used && !list_resize(list)) {
|
||||
return 0;
|
||||
@ -374,18 +374,18 @@ add_str(__ops_list_t *list, const char *str)
|
||||
|
||||
/* find a bitfield in a map - serial search */
|
||||
static const char *
|
||||
find_bitfield(__ops_bit_map_t *map, uint8_t octet)
|
||||
find_bitfield(pgp_bit_map_t *map, uint8_t octet)
|
||||
{
|
||||
__ops_bit_map_t *row;
|
||||
pgp_bit_map_t *row;
|
||||
|
||||
for (row = map; row->string != NULL && row->mask != octet ; row++) {
|
||||
}
|
||||
return (row->string) ? row->string : "Unknown";
|
||||
}
|
||||
|
||||
/* ! generic function to initialise __ops_text_t structure */
|
||||
/* ! generic function to initialise pgp_text_t structure */
|
||||
void
|
||||
__ops_text_init(__ops_text_t *text)
|
||||
pgp_text_init(pgp_text_t *text)
|
||||
{
|
||||
list_init(&text->known);
|
||||
list_init(&text->unknown);
|
||||
@ -394,12 +394,12 @@ __ops_text_init(__ops_text_t *text)
|
||||
/**
|
||||
* \ingroup Core_Print
|
||||
*
|
||||
* __ops_text_free() frees the memory used by an __ops_text_t structure
|
||||
* pgp_text_free() frees the memory used by an pgp_text_t structure
|
||||
*
|
||||
* \param text Pointer to a previously allocated structure. This structure and its contents will be freed.
|
||||
*/
|
||||
void
|
||||
__ops_text_free(__ops_text_t *text)
|
||||
pgp_text_free(pgp_text_t *text)
|
||||
{
|
||||
/* Strings in "known" array will be constants, so don't free them */
|
||||
list_free(&text->known);
|
||||
@ -417,7 +417,7 @@ __ops_text_free(__ops_text_t *text)
|
||||
/* XXX: should this (and many others) be unsigned? */
|
||||
/* ! generic function which adds text derived from single octet map to text */
|
||||
static unsigned
|
||||
add_str_from_octet_map(__ops_text_t *map, char *str, uint8_t octet)
|
||||
add_str_from_octet_map(pgp_text_t *map, char *str, uint8_t octet)
|
||||
{
|
||||
if (str && !add_str(&map->known, str)) {
|
||||
/*
|
||||
@ -449,7 +449,7 @@ add_str_from_octet_map(__ops_text_t *map, char *str, uint8_t octet)
|
||||
|
||||
/* ! generic function which adds text derived from single bit map to text */
|
||||
static unsigned
|
||||
add_bitmap_entry(__ops_text_t *map, const char *str, uint8_t bit)
|
||||
add_bitmap_entry(pgp_text_t *map, const char *str, uint8_t bit)
|
||||
{
|
||||
const char *fmt_unknown = "Unknown bit(0x%x)";
|
||||
|
||||
@ -492,23 +492,23 @@ add_bitmap_entry(__ops_text_t *map, const char *str, uint8_t bit)
|
||||
*
|
||||
*/
|
||||
|
||||
static __ops_text_t *
|
||||
text_from_bytemapped_octets(const __ops_data_t *data,
|
||||
static pgp_text_t *
|
||||
text_from_bytemapped_octets(const pgp_data_t *data,
|
||||
const char *(*text_fn)(uint8_t octet))
|
||||
{
|
||||
__ops_text_t *text;
|
||||
pgp_text_t *text;
|
||||
const char *str;
|
||||
unsigned i;
|
||||
|
||||
/*
|
||||
* ! allocate and initialise __ops_text_t structure to store derived
|
||||
* ! allocate and initialise pgp_text_t structure to store derived
|
||||
* strings
|
||||
*/
|
||||
if ((text = calloc(1, sizeof(*text))) == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
__ops_text_init(text);
|
||||
pgp_text_init(text);
|
||||
|
||||
/* ! for each octet in field ... */
|
||||
for (i = 0; i < data->len; i++) {
|
||||
@ -518,7 +518,7 @@ text_from_bytemapped_octets(const __ops_data_t *data,
|
||||
/* ! and add to text */
|
||||
if (!add_str_from_octet_map(text, netpgp_strdup(str),
|
||||
data->contents[i])) {
|
||||
__ops_text_free(text);
|
||||
pgp_text_free(text);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
@ -535,24 +535,24 @@ text_from_bytemapped_octets(const __ops_data_t *data,
|
||||
* of this byte array, derived from each bit of each octet.
|
||||
*
|
||||
*/
|
||||
static __ops_text_t *
|
||||
showall_octets_bits(__ops_data_t *data, __ops_bit_map_t **map, size_t nmap)
|
||||
static pgp_text_t *
|
||||
showall_octets_bits(pgp_data_t *data, pgp_bit_map_t **map, size_t nmap)
|
||||
{
|
||||
__ops_text_t *text;
|
||||
pgp_text_t *text;
|
||||
const char *str;
|
||||
unsigned i;
|
||||
uint8_t mask, bit;
|
||||
int j = 0;
|
||||
|
||||
/*
|
||||
* ! allocate and initialise __ops_text_t structure to store derived
|
||||
* ! allocate and initialise pgp_text_t structure to store derived
|
||||
* strings
|
||||
*/
|
||||
if ((text = calloc(1, sizeof(__ops_text_t))) == NULL) {
|
||||
if ((text = calloc(1, sizeof(pgp_text_t))) == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
__ops_text_init(text);
|
||||
pgp_text_init(text);
|
||||
|
||||
/* ! for each octet in field ... */
|
||||
for (i = 0; i < data->len; i++) {
|
||||
@ -564,7 +564,7 @@ showall_octets_bits(__ops_data_t *data, __ops_bit_map_t **map, size_t nmap)
|
||||
str = (i >= nmap) ? "Unknown" :
|
||||
find_bitfield(map[i], bit);
|
||||
if (!add_bitmap_entry(text, str, bit)) {
|
||||
__ops_text_free(text);
|
||||
pgp_text_free(text);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
@ -584,11 +584,11 @@ showall_octets_bits(__ops_data_t *data, __ops_bit_map_t **map, size_t nmap)
|
||||
* \return string or "Unknown"
|
||||
*/
|
||||
const char *
|
||||
__ops_show_packet_tag(__ops_content_enum packet_tag)
|
||||
pgp_show_packet_tag(pgp_content_enum packet_tag)
|
||||
{
|
||||
const char *ret;
|
||||
|
||||
ret = __ops_str_from_map(packet_tag, packet_tag_map);
|
||||
ret = pgp_str_from_map(packet_tag, packet_tag_map);
|
||||
if (!ret) {
|
||||
ret = "Unknown Tag";
|
||||
}
|
||||
@ -603,9 +603,9 @@ __ops_show_packet_tag(__ops_content_enum packet_tag)
|
||||
* \return string or "Unknown"
|
||||
*/
|
||||
const char *
|
||||
__ops_show_ss_type(__ops_content_enum ss_type)
|
||||
pgp_show_ss_type(pgp_content_enum ss_type)
|
||||
{
|
||||
return __ops_str_from_map(ss_type, ss_type_map);
|
||||
return pgp_str_from_map(ss_type, ss_type_map);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -616,9 +616,9 @@ __ops_show_ss_type(__ops_content_enum ss_type)
|
||||
* \return string or "Unknown"
|
||||
*/
|
||||
const char *
|
||||
__ops_show_ss_rr_code(__ops_ss_rr_code_t ss_rr_code)
|
||||
pgp_show_ss_rr_code(pgp_ss_rr_code_t ss_rr_code)
|
||||
{
|
||||
return __ops_str_from_map(ss_rr_code, ss_rr_code_map);
|
||||
return pgp_str_from_map(ss_rr_code, ss_rr_code_map);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -629,9 +629,9 @@ __ops_show_ss_rr_code(__ops_ss_rr_code_t ss_rr_code)
|
||||
* \return string or "Unknown"
|
||||
*/
|
||||
const char *
|
||||
__ops_show_sig_type(__ops_sig_type_t sig_type)
|
||||
pgp_show_sig_type(pgp_sig_type_t sig_type)
|
||||
{
|
||||
return __ops_str_from_map(sig_type, sig_type_map);
|
||||
return pgp_str_from_map(sig_type, sig_type_map);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -642,9 +642,9 @@ __ops_show_sig_type(__ops_sig_type_t sig_type)
|
||||
* \return string or "Unknown"
|
||||
*/
|
||||
const char *
|
||||
__ops_show_pka(__ops_pubkey_alg_t pka)
|
||||
pgp_show_pka(pgp_pubkey_alg_t pka)
|
||||
{
|
||||
return __ops_str_from_map(pka, pubkey_alg_map);
|
||||
return pgp_str_from_map(pka, pubkey_alg_map);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -654,9 +654,9 @@ __ops_show_pka(__ops_pubkey_alg_t pka)
|
||||
* \return string or "Unknown"
|
||||
*/
|
||||
const char *
|
||||
__ops_show_ss_zpref(uint8_t octet)
|
||||
pgp_show_ss_zpref(uint8_t octet)
|
||||
{
|
||||
return __ops_str_from_map(octet, compression_alg_map);
|
||||
return pgp_str_from_map(octet, compression_alg_map);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -667,11 +667,11 @@ __ops_show_ss_zpref(uint8_t octet)
|
||||
* \return NULL if cannot allocate memory or other error
|
||||
* \return pointer to structure, if no error
|
||||
*/
|
||||
__ops_text_t *
|
||||
__ops_showall_ss_zpref(const __ops_data_t *ss_zpref)
|
||||
pgp_text_t *
|
||||
pgp_showall_ss_zpref(const pgp_data_t *ss_zpref)
|
||||
{
|
||||
return text_from_bytemapped_octets(ss_zpref,
|
||||
&__ops_show_ss_zpref);
|
||||
&pgp_show_ss_zpref);
|
||||
}
|
||||
|
||||
|
||||
@ -683,9 +683,9 @@ __ops_showall_ss_zpref(const __ops_data_t *ss_zpref)
|
||||
* \return string or "Unknown"
|
||||
*/
|
||||
const char *
|
||||
__ops_show_hash_alg(uint8_t hash)
|
||||
pgp_show_hash_alg(uint8_t hash)
|
||||
{
|
||||
return __ops_str_from_map(hash, hash_alg_map);
|
||||
return pgp_str_from_map(hash, hash_alg_map);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -696,17 +696,17 @@ __ops_show_hash_alg(uint8_t hash)
|
||||
* \return NULL if cannot allocate memory or other error
|
||||
* \return pointer to structure, if no error
|
||||
*/
|
||||
__ops_text_t *
|
||||
__ops_showall_ss_hashpref(const __ops_data_t *ss_hashpref)
|
||||
pgp_text_t *
|
||||
pgp_showall_ss_hashpref(const pgp_data_t *ss_hashpref)
|
||||
{
|
||||
return text_from_bytemapped_octets(ss_hashpref,
|
||||
&__ops_show_hash_alg);
|
||||
&pgp_show_hash_alg);
|
||||
}
|
||||
|
||||
const char *
|
||||
__ops_show_symm_alg(uint8_t hash)
|
||||
pgp_show_symm_alg(uint8_t hash)
|
||||
{
|
||||
return __ops_str_from_map(hash, symm_alg_map);
|
||||
return pgp_str_from_map(hash, symm_alg_map);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -716,9 +716,9 @@ __ops_show_symm_alg(uint8_t hash)
|
||||
* \return string or "Unknown"
|
||||
*/
|
||||
const char *
|
||||
__ops_show_ss_skapref(uint8_t octet)
|
||||
pgp_show_ss_skapref(uint8_t octet)
|
||||
{
|
||||
return __ops_str_from_map(octet, symm_alg_map);
|
||||
return pgp_str_from_map(octet, symm_alg_map);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -729,11 +729,11 @@ __ops_show_ss_skapref(uint8_t octet)
|
||||
* \return NULL if cannot allocate memory or other error
|
||||
* \return pointer to structure, if no error
|
||||
*/
|
||||
__ops_text_t *
|
||||
__ops_showall_ss_skapref(const __ops_data_t *ss_skapref)
|
||||
pgp_text_t *
|
||||
pgp_showall_ss_skapref(const pgp_data_t *ss_skapref)
|
||||
{
|
||||
return text_from_bytemapped_octets(ss_skapref,
|
||||
&__ops_show_ss_skapref);
|
||||
&pgp_show_ss_skapref);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -743,9 +743,9 @@ __ops_showall_ss_skapref(const __ops_data_t *ss_skapref)
|
||||
* \return string or "Unknown"
|
||||
*/
|
||||
static const char *
|
||||
__ops_show_ss_feature(uint8_t octet, unsigned offset)
|
||||
pgp_show_ss_feature(uint8_t octet, unsigned offset)
|
||||
{
|
||||
if (offset >= OPS_ARRAY_SIZE(ss_feature_map)) {
|
||||
if (offset >= PGP_ARRAY_SIZE(ss_feature_map)) {
|
||||
return "Unknown";
|
||||
}
|
||||
return find_bitfield(ss_feature_map[offset], octet);
|
||||
@ -760,10 +760,10 @@ __ops_show_ss_feature(uint8_t octet, unsigned offset)
|
||||
* \return pointer to structure, if no error
|
||||
*/
|
||||
/* XXX: shouldn't this use show_all_octets_bits? */
|
||||
__ops_text_t *
|
||||
__ops_showall_ss_features(__ops_data_t ss_features)
|
||||
pgp_text_t *
|
||||
pgp_showall_ss_features(pgp_data_t ss_features)
|
||||
{
|
||||
__ops_text_t *text;
|
||||
pgp_text_t *text;
|
||||
const char *str;
|
||||
unsigned i;
|
||||
uint8_t mask, bit;
|
||||
@ -773,16 +773,16 @@ __ops_showall_ss_features(__ops_data_t ss_features)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
__ops_text_init(text);
|
||||
pgp_text_init(text);
|
||||
|
||||
for (i = 0; i < ss_features.len; i++) {
|
||||
mask = 0x80;
|
||||
for (j = 0; j < 8; j++, mask = (unsigned)mask >> 1) {
|
||||
bit = ss_features.contents[i] & mask;
|
||||
if (bit) {
|
||||
str = __ops_show_ss_feature(bit, i);
|
||||
str = pgp_show_ss_feature(bit, i);
|
||||
if (!add_bitmap_entry(text, str, bit)) {
|
||||
__ops_text_free(text);
|
||||
pgp_text_free(text);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
@ -799,7 +799,7 @@ __ops_showall_ss_features(__ops_data_t ss_features)
|
||||
* \return
|
||||
*/
|
||||
const char *
|
||||
__ops_show_ss_key_flag(uint8_t octet, __ops_bit_map_t *map)
|
||||
pgp_show_ss_key_flag(uint8_t octet, pgp_bit_map_t *map)
|
||||
{
|
||||
return find_bitfield(map, octet);
|
||||
}
|
||||
@ -812,10 +812,10 @@ __ops_show_ss_key_flag(uint8_t octet, __ops_bit_map_t *map)
|
||||
* \return NULL if cannot allocate memory or other error
|
||||
* \return pointer to structure, if no error
|
||||
*/
|
||||
__ops_text_t *
|
||||
__ops_showall_ss_key_flags(const __ops_data_t *ss_key_flags)
|
||||
pgp_text_t *
|
||||
pgp_showall_ss_key_flags(const pgp_data_t *ss_key_flags)
|
||||
{
|
||||
__ops_text_t *text;
|
||||
pgp_text_t *text;
|
||||
const char *str;
|
||||
uint8_t mask, bit;
|
||||
int i;
|
||||
@ -824,15 +824,15 @@ __ops_showall_ss_key_flags(const __ops_data_t *ss_key_flags)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
__ops_text_init(text);
|
||||
pgp_text_init(text);
|
||||
|
||||
/* xxx - TBD: extend to handle multiple octets of bits - rachel */
|
||||
for (i = 0, mask = 0x80; i < 8; i++, mask = (unsigned)mask >> 1) {
|
||||
bit = ss_key_flags->contents[0] & mask;
|
||||
if (bit) {
|
||||
str = __ops_show_ss_key_flag(bit, ss_key_flags_map);
|
||||
str = pgp_show_ss_key_flag(bit, ss_key_flags_map);
|
||||
if (!add_bitmap_entry(text, netpgp_strdup(str), bit)) {
|
||||
__ops_text_free(text);
|
||||
pgp_text_free(text);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
@ -854,7 +854,7 @@ __ops_showall_ss_key_flags(const __ops_data_t *ss_key_flags)
|
||||
* \return string or "Unknown"
|
||||
*/
|
||||
const char *
|
||||
__ops_show_keyserv_pref(uint8_t prefs, __ops_bit_map_t *map)
|
||||
pgp_show_keyserv_pref(uint8_t prefs, pgp_bit_map_t *map)
|
||||
{
|
||||
return find_bitfield(map, prefs);
|
||||
}
|
||||
@ -867,10 +867,10 @@ __ops_show_keyserv_pref(uint8_t prefs, __ops_bit_map_t *map)
|
||||
* \return pointer to structure, if no error
|
||||
*
|
||||
*/
|
||||
__ops_text_t *
|
||||
__ops_show_keyserv_prefs(const __ops_data_t *prefs)
|
||||
pgp_text_t *
|
||||
pgp_show_keyserv_prefs(const pgp_data_t *prefs)
|
||||
{
|
||||
__ops_text_t *text;
|
||||
pgp_text_t *text;
|
||||
const char *str;
|
||||
uint8_t mask, bit;
|
||||
int i = 0;
|
||||
@ -879,17 +879,17 @@ __ops_show_keyserv_prefs(const __ops_data_t *prefs)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
__ops_text_init(text);
|
||||
pgp_text_init(text);
|
||||
|
||||
/* xxx - TBD: extend to handle multiple octets of bits - rachel */
|
||||
|
||||
for (i = 0, mask = 0x80; i < 8; i++, mask = (unsigned)mask >> 1) {
|
||||
bit = prefs->contents[0] & mask;
|
||||
if (bit) {
|
||||
str = __ops_show_keyserv_pref(bit,
|
||||
str = pgp_show_keyserv_pref(bit,
|
||||
ss_key_server_prefs_map);
|
||||
if (!add_bitmap_entry(text, netpgp_strdup(str), bit)) {
|
||||
__ops_text_free(text);
|
||||
pgp_text_free(text);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
@ -909,10 +909,10 @@ __ops_show_keyserv_prefs(const __ops_data_t *prefs)
|
||||
* \return NULL if cannot allocate memory or other error
|
||||
* \return pointer to structure, if no error
|
||||
*/
|
||||
__ops_text_t *
|
||||
__ops_showall_notation(__ops_ss_notation_t ss_notation)
|
||||
pgp_text_t *
|
||||
pgp_showall_notation(pgp_ss_notation_t ss_notation)
|
||||
{
|
||||
return showall_octets_bits(&ss_notation.flags,
|
||||
ss_notation_map,
|
||||
OPS_ARRAY_SIZE(ss_notation_map));
|
||||
PGP_ARRAY_SIZE(ss_notation_map));
|
||||
}
|
||||
|
@ -55,57 +55,57 @@
|
||||
|
||||
#include "packet.h"
|
||||
|
||||
/** __ops_list_t
|
||||
/** pgp_list_t
|
||||
*/
|
||||
typedef struct {
|
||||
unsigned size; /* num of array slots allocated */
|
||||
unsigned used; /* num of array slots currently used */
|
||||
char **strings;
|
||||
} __ops_list_t;
|
||||
} pgp_list_t;
|
||||
|
||||
/** __ops_text_t
|
||||
/** pgp_text_t
|
||||
*/
|
||||
typedef struct {
|
||||
__ops_list_t known;
|
||||
__ops_list_t unknown;
|
||||
} __ops_text_t;
|
||||
pgp_list_t known;
|
||||
pgp_list_t unknown;
|
||||
} pgp_text_t;
|
||||
|
||||
/** __ops_bit_map_t
|
||||
/** pgp_bit_map_t
|
||||
*/
|
||||
typedef struct {
|
||||
uint8_t mask;
|
||||
const char *string;
|
||||
} __ops_bit_map_t;
|
||||
} pgp_bit_map_t;
|
||||
|
||||
void __ops_text_init(__ops_text_t *);
|
||||
void __ops_text_free(__ops_text_t *);
|
||||
void pgp_text_init(pgp_text_t *);
|
||||
void pgp_text_free(pgp_text_t *);
|
||||
|
||||
const char *__ops_show_packet_tag(__ops_content_enum);
|
||||
const char *__ops_show_ss_type(__ops_content_enum);
|
||||
const char *pgp_show_packet_tag(pgp_content_enum);
|
||||
const char *pgp_show_ss_type(pgp_content_enum);
|
||||
|
||||
const char *__ops_show_sig_type(__ops_sig_type_t);
|
||||
const char *__ops_show_pka(__ops_pubkey_alg_t);
|
||||
const char *pgp_show_sig_type(pgp_sig_type_t);
|
||||
const char *pgp_show_pka(pgp_pubkey_alg_t);
|
||||
|
||||
__ops_text_t *__ops_showall_ss_zpref(const __ops_data_t *);
|
||||
const char *__ops_show_ss_zpref(uint8_t);
|
||||
pgp_text_t *pgp_showall_ss_zpref(const pgp_data_t *);
|
||||
const char *pgp_show_ss_zpref(uint8_t);
|
||||
|
||||
__ops_text_t *__ops_showall_ss_hashpref(const __ops_data_t *);
|
||||
const char *__ops_show_hash_alg(uint8_t);
|
||||
const char *__ops_show_symm_alg(uint8_t);
|
||||
pgp_text_t *pgp_showall_ss_hashpref(const pgp_data_t *);
|
||||
const char *pgp_show_hash_alg(uint8_t);
|
||||
const char *pgp_show_symm_alg(uint8_t);
|
||||
|
||||
__ops_text_t *__ops_showall_ss_skapref(const __ops_data_t *);
|
||||
const char *__ops_show_ss_skapref(uint8_t);
|
||||
pgp_text_t *pgp_showall_ss_skapref(const pgp_data_t *);
|
||||
const char *pgp_show_ss_skapref(uint8_t);
|
||||
|
||||
const char *__ops_show_ss_rr_code(__ops_ss_rr_code_t);
|
||||
const char *pgp_show_ss_rr_code(pgp_ss_rr_code_t);
|
||||
|
||||
__ops_text_t *__ops_showall_ss_features(__ops_data_t);
|
||||
pgp_text_t *pgp_showall_ss_features(pgp_data_t);
|
||||
|
||||
__ops_text_t *__ops_showall_ss_key_flags(const __ops_data_t *);
|
||||
const char *__ops_show_ss_key_flag(uint8_t, __ops_bit_map_t *);
|
||||
pgp_text_t *pgp_showall_ss_key_flags(const pgp_data_t *);
|
||||
const char *pgp_show_ss_key_flag(uint8_t, pgp_bit_map_t *);
|
||||
|
||||
__ops_text_t *__ops_show_keyserv_prefs(const __ops_data_t *);
|
||||
const char *__ops_show_keyserv_pref(uint8_t, __ops_bit_map_t *);
|
||||
pgp_text_t *pgp_show_keyserv_prefs(const pgp_data_t *);
|
||||
const char *pgp_show_keyserv_pref(uint8_t, pgp_bit_map_t *);
|
||||
|
||||
__ops_text_t *__ops_showall_notation(__ops_ss_notation_t);
|
||||
pgp_text_t *pgp_showall_notation(pgp_ss_notation_t);
|
||||
|
||||
#endif /* PACKET_SHOW_H_ */
|
||||
|
820
crypto/external/bsd/netpgp/dist/src/lib/packet.h
vendored
820
crypto/external/bsd/netpgp/dist/src/lib/packet.h
vendored
File diff suppressed because it is too large
Load Diff
636
crypto/external/bsd/netpgp/dist/src/lib/reader.c
vendored
636
crypto/external/bsd/netpgp/dist/src/lib/reader.c
vendored
File diff suppressed because it is too large
Load Diff
@ -57,70 +57,70 @@
|
||||
/* if this is defined, we'll use mmap in preference to file ops */
|
||||
#define USE_MMAP_FOR_FILES 1
|
||||
|
||||
void __ops_reader_set_fd(__ops_stream_t *, int);
|
||||
void __ops_reader_set_mmap(__ops_stream_t *, int);
|
||||
void __ops_reader_set_memory(__ops_stream_t *, const void *, size_t);
|
||||
void pgp_reader_set_fd(pgp_stream_t *, int);
|
||||
void pgp_reader_set_mmap(pgp_stream_t *, int);
|
||||
void pgp_reader_set_memory(pgp_stream_t *, const void *, size_t);
|
||||
|
||||
/* Do a sum mod 65536 of all bytes read (as needed for secret keys) */
|
||||
void __ops_reader_push_sum16(__ops_stream_t *);
|
||||
uint16_t __ops_reader_pop_sum16(__ops_stream_t *);
|
||||
void pgp_reader_push_sum16(pgp_stream_t *);
|
||||
uint16_t pgp_reader_pop_sum16(pgp_stream_t *);
|
||||
|
||||
void __ops_reader_push_se_ip_data(__ops_stream_t *, __ops_crypt_t *,
|
||||
__ops_region_t *);
|
||||
void __ops_reader_pop_se_ip_data(__ops_stream_t *);
|
||||
void pgp_reader_push_se_ip_data(pgp_stream_t *, pgp_crypt_t *,
|
||||
pgp_region_t *);
|
||||
void pgp_reader_pop_se_ip_data(pgp_stream_t *);
|
||||
|
||||
/* */
|
||||
unsigned __ops_write_mdc(__ops_output_t *, const uint8_t *);
|
||||
unsigned __ops_write_se_ip_pktset(__ops_output_t *, const uint8_t *,
|
||||
unsigned pgp_write_mdc(pgp_output_t *, const uint8_t *);
|
||||
unsigned pgp_write_se_ip_pktset(pgp_output_t *, const uint8_t *,
|
||||
const unsigned,
|
||||
__ops_crypt_t *);
|
||||
void __ops_push_enc_crypt(__ops_output_t *, __ops_crypt_t *);
|
||||
int __ops_push_enc_se_ip(__ops_output_t *, const __ops_key_t *, const char *);
|
||||
pgp_crypt_t *);
|
||||
void pgp_push_enc_crypt(pgp_output_t *, pgp_crypt_t *);
|
||||
int pgp_push_enc_se_ip(pgp_output_t *, const pgp_key_t *, const char *);
|
||||
|
||||
/* Secret Key checksum */
|
||||
void __ops_push_checksum_writer(__ops_output_t *, __ops_seckey_t *);
|
||||
unsigned __ops_pop_skey_checksum_writer(__ops_output_t *);
|
||||
void pgp_push_checksum_writer(pgp_output_t *, pgp_seckey_t *);
|
||||
unsigned pgp_pop_skey_checksum_writer(pgp_output_t *);
|
||||
|
||||
|
||||
/* memory writing */
|
||||
void __ops_setup_memory_write(__ops_output_t **, __ops_memory_t **, size_t);
|
||||
void __ops_teardown_memory_write(__ops_output_t *, __ops_memory_t *);
|
||||
void pgp_setup_memory_write(pgp_output_t **, pgp_memory_t **, size_t);
|
||||
void pgp_teardown_memory_write(pgp_output_t *, pgp_memory_t *);
|
||||
|
||||
/* memory reading */
|
||||
void __ops_setup_memory_read(__ops_io_t *,
|
||||
__ops_stream_t **,
|
||||
__ops_memory_t *,
|
||||
void pgp_setup_memory_read(pgp_io_t *,
|
||||
pgp_stream_t **,
|
||||
pgp_memory_t *,
|
||||
void *,
|
||||
__ops_cb_ret_t callback(const __ops_packet_t *,
|
||||
__ops_cbdata_t *),
|
||||
pgp_cb_ret_t callback(const pgp_packet_t *,
|
||||
pgp_cbdata_t *),
|
||||
unsigned);
|
||||
void __ops_teardown_memory_read(__ops_stream_t *, __ops_memory_t *);
|
||||
void pgp_teardown_memory_read(pgp_stream_t *, pgp_memory_t *);
|
||||
|
||||
/* file writing */
|
||||
int __ops_setup_file_write(__ops_output_t **, const char *, unsigned);
|
||||
void __ops_teardown_file_write(__ops_output_t *, int);
|
||||
int pgp_setup_file_write(pgp_output_t **, const char *, unsigned);
|
||||
void pgp_teardown_file_write(pgp_output_t *, int);
|
||||
|
||||
/* file appending */
|
||||
int __ops_setup_file_append(__ops_output_t **, const char *);
|
||||
void __ops_teardown_file_append(__ops_output_t *, int);
|
||||
int pgp_setup_file_append(pgp_output_t **, const char *);
|
||||
void pgp_teardown_file_append(pgp_output_t *, int);
|
||||
|
||||
/* file reading */
|
||||
int __ops_setup_file_read(__ops_io_t *,
|
||||
__ops_stream_t **,
|
||||
int pgp_setup_file_read(pgp_io_t *,
|
||||
pgp_stream_t **,
|
||||
const char *,
|
||||
void *,
|
||||
__ops_cb_ret_t callback(const __ops_packet_t *,
|
||||
__ops_cbdata_t *),
|
||||
pgp_cb_ret_t callback(const pgp_packet_t *,
|
||||
pgp_cbdata_t *),
|
||||
unsigned);
|
||||
void __ops_teardown_file_read(__ops_stream_t *, int);
|
||||
void pgp_teardown_file_read(pgp_stream_t *, int);
|
||||
|
||||
unsigned __ops_reader_set_accumulate(__ops_stream_t *, unsigned);
|
||||
unsigned pgp_reader_set_accumulate(pgp_stream_t *, unsigned);
|
||||
|
||||
/* useful callbacks */
|
||||
__ops_cb_ret_t __ops_litdata_cb(const __ops_packet_t *, __ops_cbdata_t *);
|
||||
__ops_cb_ret_t __ops_pk_sesskey_cb(const __ops_packet_t *, __ops_cbdata_t *);
|
||||
__ops_cb_ret_t __ops_get_seckey_cb(const __ops_packet_t *, __ops_cbdata_t *);
|
||||
pgp_cb_ret_t pgp_litdata_cb(const pgp_packet_t *, pgp_cbdata_t *);
|
||||
pgp_cb_ret_t pgp_pk_sesskey_cb(const pgp_packet_t *, pgp_cbdata_t *);
|
||||
pgp_cb_ret_t pgp_get_seckey_cb(const pgp_packet_t *, pgp_cbdata_t *);
|
||||
|
||||
int __ops_getpassphrase(void *, char *, size_t);
|
||||
int pgp_getpassphrase(void *, char *, size_t);
|
||||
|
||||
#endif /* READERWRITER_H_ */
|
||||
|
622
crypto/external/bsd/netpgp/dist/src/lib/signature.c
vendored
622
crypto/external/bsd/netpgp/dist/src/lib/signature.c
vendored
File diff suppressed because it is too large
Load Diff
116
crypto/external/bsd/netpgp/dist/src/lib/signature.h
vendored
116
crypto/external/bsd/netpgp/dist/src/lib/signature.h
vendored
@ -61,57 +61,57 @@
|
||||
#include "create.h"
|
||||
#include "memory.h"
|
||||
|
||||
typedef struct __ops_create_sig_t __ops_create_sig_t;
|
||||
typedef struct pgp_create_sig_t pgp_create_sig_t;
|
||||
|
||||
__ops_create_sig_t *__ops_create_sig_new(void);
|
||||
void __ops_create_sig_delete(__ops_create_sig_t *);
|
||||
pgp_create_sig_t *pgp_create_sig_new(void);
|
||||
void pgp_create_sig_delete(pgp_create_sig_t *);
|
||||
|
||||
unsigned __ops_check_useridcert_sig(const __ops_pubkey_t *,
|
||||
unsigned pgp_check_useridcert_sig(const pgp_pubkey_t *,
|
||||
const uint8_t *,
|
||||
const __ops_sig_t *,
|
||||
const __ops_pubkey_t *,
|
||||
const pgp_sig_t *,
|
||||
const pgp_pubkey_t *,
|
||||
const uint8_t *);
|
||||
unsigned __ops_check_userattrcert_sig(const __ops_pubkey_t *,
|
||||
const __ops_data_t *,
|
||||
const __ops_sig_t *,
|
||||
const __ops_pubkey_t *,
|
||||
unsigned pgp_check_userattrcert_sig(const pgp_pubkey_t *,
|
||||
const pgp_data_t *,
|
||||
const pgp_sig_t *,
|
||||
const pgp_pubkey_t *,
|
||||
const uint8_t *);
|
||||
unsigned __ops_check_subkey_sig(const __ops_pubkey_t *,
|
||||
const __ops_pubkey_t *,
|
||||
const __ops_sig_t *,
|
||||
const __ops_pubkey_t *,
|
||||
unsigned pgp_check_subkey_sig(const pgp_pubkey_t *,
|
||||
const pgp_pubkey_t *,
|
||||
const pgp_sig_t *,
|
||||
const pgp_pubkey_t *,
|
||||
const uint8_t *);
|
||||
unsigned __ops_check_direct_sig(const __ops_pubkey_t *,
|
||||
const __ops_sig_t *,
|
||||
const __ops_pubkey_t *,
|
||||
unsigned pgp_check_direct_sig(const pgp_pubkey_t *,
|
||||
const pgp_sig_t *,
|
||||
const pgp_pubkey_t *,
|
||||
const uint8_t *);
|
||||
unsigned __ops_check_hash_sig(__ops_hash_t *,
|
||||
const __ops_sig_t *,
|
||||
const __ops_pubkey_t *);
|
||||
void __ops_sig_start_key_sig(__ops_create_sig_t *,
|
||||
const __ops_pubkey_t *,
|
||||
unsigned pgp_check_hash_sig(pgp_hash_t *,
|
||||
const pgp_sig_t *,
|
||||
const pgp_pubkey_t *);
|
||||
void pgp_sig_start_key_sig(pgp_create_sig_t *,
|
||||
const pgp_pubkey_t *,
|
||||
const uint8_t *,
|
||||
__ops_sig_type_t);
|
||||
void __ops_start_sig(__ops_create_sig_t *,
|
||||
const __ops_seckey_t *,
|
||||
const __ops_hash_alg_t,
|
||||
const __ops_sig_type_t);
|
||||
pgp_sig_type_t);
|
||||
void pgp_start_sig(pgp_create_sig_t *,
|
||||
const pgp_seckey_t *,
|
||||
const pgp_hash_alg_t,
|
||||
const pgp_sig_type_t);
|
||||
|
||||
void __ops_sig_add_data(__ops_create_sig_t *, const void *, size_t);
|
||||
__ops_hash_t *__ops_sig_get_hash(__ops_create_sig_t *);
|
||||
unsigned __ops_end_hashed_subpkts(__ops_create_sig_t *);
|
||||
unsigned __ops_write_sig(__ops_output_t *, __ops_create_sig_t *,
|
||||
const __ops_pubkey_t *, const __ops_seckey_t *);
|
||||
unsigned __ops_add_time(__ops_create_sig_t *, int64_t, const char *);
|
||||
unsigned __ops_add_issuer_keyid(__ops_create_sig_t *,
|
||||
void pgp_sig_add_data(pgp_create_sig_t *, const void *, size_t);
|
||||
pgp_hash_t *pgp_sig_get_hash(pgp_create_sig_t *);
|
||||
unsigned pgp_end_hashed_subpkts(pgp_create_sig_t *);
|
||||
unsigned pgp_write_sig(pgp_output_t *, pgp_create_sig_t *,
|
||||
const pgp_pubkey_t *, const pgp_seckey_t *);
|
||||
unsigned pgp_add_time(pgp_create_sig_t *, int64_t, const char *);
|
||||
unsigned pgp_add_issuer_keyid(pgp_create_sig_t *,
|
||||
const uint8_t *);
|
||||
void __ops_add_primary_userid(__ops_create_sig_t *, unsigned);
|
||||
void pgp_add_primary_userid(pgp_create_sig_t *, unsigned);
|
||||
|
||||
/* Standard Interface */
|
||||
unsigned __ops_sign_file(__ops_io_t *,
|
||||
unsigned pgp_sign_file(pgp_io_t *,
|
||||
const char *,
|
||||
const char *,
|
||||
const __ops_seckey_t *,
|
||||
const pgp_seckey_t *,
|
||||
const char *,
|
||||
const int64_t,
|
||||
const uint64_t,
|
||||
@ -119,10 +119,10 @@ unsigned __ops_sign_file(__ops_io_t *,
|
||||
const unsigned,
|
||||
const unsigned);
|
||||
|
||||
int __ops_sign_detached(__ops_io_t *,
|
||||
int pgp_sign_detached(pgp_io_t *,
|
||||
const char *,
|
||||
char *,
|
||||
__ops_seckey_t *,
|
||||
pgp_seckey_t *,
|
||||
const char *,
|
||||
const int64_t,
|
||||
const uint64_t,
|
||||
@ -130,42 +130,42 @@ int __ops_sign_detached(__ops_io_t *,
|
||||
const unsigned);
|
||||
|
||||
/* armoured stuff */
|
||||
unsigned __ops_crc24(unsigned, uint8_t);
|
||||
unsigned pgp_crc24(unsigned, uint8_t);
|
||||
|
||||
void __ops_reader_push_dearmour(__ops_stream_t *);
|
||||
void pgp_reader_push_dearmour(pgp_stream_t *);
|
||||
|
||||
void __ops_reader_pop_dearmour(__ops_stream_t *);
|
||||
unsigned __ops_writer_push_clearsigned(__ops_output_t *, __ops_create_sig_t *);
|
||||
void __ops_writer_push_armor_msg(__ops_output_t *);
|
||||
void pgp_reader_pop_dearmour(pgp_stream_t *);
|
||||
unsigned pgp_writer_push_clearsigned(pgp_output_t *, pgp_create_sig_t *);
|
||||
void pgp_writer_push_armor_msg(pgp_output_t *);
|
||||
|
||||
typedef enum {
|
||||
OPS_PGP_MESSAGE = 1,
|
||||
OPS_PGP_PUBLIC_KEY_BLOCK,
|
||||
OPS_PGP_PRIVATE_KEY_BLOCK,
|
||||
OPS_PGP_MULTIPART_MESSAGE_PART_X_OF_Y,
|
||||
OPS_PGP_MULTIPART_MESSAGE_PART_X,
|
||||
OPS_PGP_SIGNATURE
|
||||
} __ops_armor_type_t;
|
||||
PGP_PGP_MESSAGE = 1,
|
||||
PGP_PGP_PUBLIC_KEY_BLOCK,
|
||||
PGP_PGP_PRIVATE_KEY_BLOCK,
|
||||
PGP_PGP_MULTIPART_MESSAGE_PART_X_OF_Y,
|
||||
PGP_PGP_MULTIPART_MESSAGE_PART_X,
|
||||
PGP_PGP_SIGNATURE
|
||||
} pgp_armor_type_t;
|
||||
|
||||
#define CRC24_INIT 0xb704ceL
|
||||
|
||||
unsigned __ops_writer_use_armored_sig(__ops_output_t *);
|
||||
unsigned pgp_writer_use_armored_sig(pgp_output_t *);
|
||||
|
||||
void __ops_writer_push_armoured(__ops_output_t *, __ops_armor_type_t);
|
||||
void pgp_writer_push_armoured(pgp_output_t *, pgp_armor_type_t);
|
||||
|
||||
__ops_memory_t *__ops_sign_buf(__ops_io_t *,
|
||||
pgp_memory_t *pgp_sign_buf(pgp_io_t *,
|
||||
const void *,
|
||||
const size_t,
|
||||
const __ops_seckey_t *,
|
||||
const pgp_seckey_t *,
|
||||
const int64_t,
|
||||
const uint64_t,
|
||||
const char *,
|
||||
const unsigned,
|
||||
const unsigned);
|
||||
|
||||
unsigned __ops_keyring_read_from_mem(__ops_io_t *,
|
||||
__ops_keyring_t *,
|
||||
unsigned pgp_keyring_read_from_mem(pgp_io_t *,
|
||||
pgp_keyring_t *,
|
||||
const unsigned,
|
||||
__ops_memory_t *);
|
||||
pgp_memory_t *);
|
||||
|
||||
#endif /* SIGNATURE_H_ */
|
||||
|
114
crypto/external/bsd/netpgp/dist/src/lib/ssh2pgp.c
vendored
114
crypto/external/bsd/netpgp/dist/src/lib/ssh2pgp.c
vendored
@ -153,7 +153,7 @@ getbignum(bufgap_t *bg, char *buf, const char *header)
|
||||
(void) bufgap_seek(bg, sizeof(len), BGFromHere, BGByte);
|
||||
(void) bufgap_getbin(bg, buf, len);
|
||||
bignum = BN_bin2bn((const uint8_t *)buf, (int)len, NULL);
|
||||
if (__ops_get_debug_level(__FILE__)) {
|
||||
if (pgp_get_debug_level(__FILE__)) {
|
||||
hexdump(stderr, header, (const uint8_t *)(void *)buf, len);
|
||||
}
|
||||
(void) bufgap_seek(bg, len, BGFromHere, BGByte);
|
||||
@ -170,7 +170,7 @@ putbignum(bufgap_t *bg, BIGNUM *bignum)
|
||||
(void) bufgap_insert(bg, &len, sizeof(len));
|
||||
(void) bufgap_insert(bg, buf, len);
|
||||
bignum = BN_bin2bn((const uint8_t *)buf, (int)len, NULL);
|
||||
if (__ops_get_debug_level(__FILE__)) {
|
||||
if (pgp_get_debug_level(__FILE__)) {
|
||||
hexdump(stderr, header, buf, (int)len);
|
||||
}
|
||||
(void) bufgap_seek(bg, len, BGFromHere, BGByte);
|
||||
@ -179,9 +179,9 @@ putbignum(bufgap_t *bg, BIGNUM *bignum)
|
||||
#endif
|
||||
|
||||
static str_t pkatypes[] = {
|
||||
{ "ssh-rsa", 7, OPS_PKA_RSA },
|
||||
{ "ssh-dss", 7, OPS_PKA_DSA },
|
||||
{ "ssh-dsa", 7, OPS_PKA_DSA },
|
||||
{ "ssh-rsa", 7, PGP_PKA_RSA },
|
||||
{ "ssh-dss", 7, PGP_PKA_DSA },
|
||||
{ "ssh-dsa", 7, PGP_PKA_DSA },
|
||||
{ NULL, 0, 0 }
|
||||
};
|
||||
|
||||
@ -201,9 +201,9 @@ findstr(str_t *array, const char *name)
|
||||
|
||||
/* convert an ssh (host) pubkey to a pgp pubkey */
|
||||
int
|
||||
__ops_ssh2pubkey(__ops_io_t *io, const char *f, __ops_key_t *key, __ops_hash_alg_t hashtype)
|
||||
pgp_ssh2pubkey(pgp_io_t *io, const char *f, pgp_key_t *key, pgp_hash_alg_t hashtype)
|
||||
{
|
||||
__ops_pubkey_t *pubkey;
|
||||
pgp_pubkey_t *pubkey;
|
||||
struct stat st;
|
||||
bufgap_t bg;
|
||||
uint32_t len;
|
||||
@ -219,7 +219,7 @@ __ops_ssh2pubkey(__ops_io_t *io, const char *f, __ops_key_t *key, __ops_hash_alg
|
||||
|
||||
(void) memset(&bg, 0x0, sizeof(bg));
|
||||
if (!bufgap_open(&bg, f)) {
|
||||
(void) fprintf(stderr, "__ops_ssh2pubkey: can't open '%s'\n", f);
|
||||
(void) fprintf(stderr, "pgp_ssh2pubkey: can't open '%s'\n", f);
|
||||
return 0;
|
||||
}
|
||||
(void)stat(f, &st);
|
||||
@ -254,11 +254,11 @@ __ops_ssh2pubkey(__ops_io_t *io, const char *f, __ops_key_t *key, __ops_hash_alg
|
||||
if ((space = strchr(buf, ' ')) != NULL) {
|
||||
cc = (int)(space - buf);
|
||||
}
|
||||
if (__ops_get_debug_level(__FILE__)) {
|
||||
if (pgp_get_debug_level(__FILE__)) {
|
||||
hexdump(stderr, NULL, (const uint8_t *)(const void *)buf, (size_t)cc);
|
||||
}
|
||||
cc = frombase64(bin, buf, (size_t)cc, 0);
|
||||
if (__ops_get_debug_level(__FILE__)) {
|
||||
if (pgp_get_debug_level(__FILE__)) {
|
||||
hexdump(stderr, "decoded base64:", (const uint8_t *)(const void *)bin, (size_t)cc);
|
||||
}
|
||||
bufgap_delete(&bg, (uint64_t)bufgap_tell(&bg, BGFromEOF, BGByte));
|
||||
@ -274,18 +274,18 @@ __ops_ssh2pubkey(__ops_io_t *io, const char *f, __ops_key_t *key, __ops_hash_alg
|
||||
|
||||
(void) memset(key, 0x0, sizeof(*key));
|
||||
pubkey = &key->key.seckey.pubkey;
|
||||
pubkey->version = OPS_V4;
|
||||
pubkey->version = PGP_V4;
|
||||
pubkey->birthtime = st.st_mtime;
|
||||
/* get key type */
|
||||
ok = 1;
|
||||
switch (pubkey->alg = findstr(pkatypes, buf)) {
|
||||
case OPS_PKA_RSA:
|
||||
case PGP_PKA_RSA:
|
||||
/* get the 'e' param of the key */
|
||||
pubkey->key.rsa.e = getbignum(&bg, buf, "RSA E");
|
||||
/* get the 'n' param of the key */
|
||||
pubkey->key.rsa.n = getbignum(&bg, buf, "RSA N");
|
||||
break;
|
||||
case OPS_PKA_DSA:
|
||||
case PGP_PKA_DSA:
|
||||
/* get the 'p' param of the key */
|
||||
pubkey->key.dsa.p = getbignum(&bg, buf, "DSA P");
|
||||
/* get the 'q' param of the key */
|
||||
@ -319,18 +319,18 @@ __ops_ssh2pubkey(__ops_io_t *io, const char *f, __ops_key_t *key, __ops_hash_alg
|
||||
(int)strlen(space + 1) - 1,
|
||||
space + 1);
|
||||
}
|
||||
(void) __ops_asprintf((char **)(void *)&userid,
|
||||
(void) pgp_asprintf((char **)(void *)&userid,
|
||||
"%s (%s) %s",
|
||||
hostname,
|
||||
f,
|
||||
owner);
|
||||
__ops_keyid(key->sigid, sizeof(key->sigid), pubkey, hashtype);
|
||||
__ops_add_userid(key, userid);
|
||||
__ops_fingerprint(&key->sigfingerprint, pubkey, hashtype);
|
||||
pgp_keyid(key->sigid, sizeof(key->sigid), pubkey, hashtype);
|
||||
pgp_add_userid(key, userid);
|
||||
pgp_fingerprint(&key->sigfingerprint, pubkey, hashtype);
|
||||
free(userid);
|
||||
if (__ops_get_debug_level(__FILE__)) {
|
||||
/*__ops_print_keydata(io, keyring, key, "pub", pubkey, 0);*/
|
||||
__OPS_USED(io); /* XXX */
|
||||
if (pgp_get_debug_level(__FILE__)) {
|
||||
/*pgp_print_keydata(io, keyring, key, "pub", pubkey, 0);*/
|
||||
__PGP_USED(io); /* XXX */
|
||||
}
|
||||
}
|
||||
(void) free(bin);
|
||||
@ -341,32 +341,32 @@ __ops_ssh2pubkey(__ops_io_t *io, const char *f, __ops_key_t *key, __ops_hash_alg
|
||||
|
||||
/* convert an ssh (host) seckey to a pgp seckey */
|
||||
int
|
||||
__ops_ssh2seckey(__ops_io_t *io, const char *f, __ops_key_t *key, __ops_pubkey_t *pubkey, __ops_hash_alg_t hashtype)
|
||||
pgp_ssh2seckey(pgp_io_t *io, const char *f, pgp_key_t *key, pgp_pubkey_t *pubkey, pgp_hash_alg_t hashtype)
|
||||
{
|
||||
__ops_crypt_t crypted;
|
||||
__ops_hash_t hash;
|
||||
pgp_crypt_t crypted;
|
||||
pgp_hash_t hash;
|
||||
unsigned done = 0;
|
||||
unsigned i = 0;
|
||||
uint8_t sesskey[CAST_KEY_LENGTH];
|
||||
uint8_t hashed[OPS_SHA1_HASH_SIZE];
|
||||
uint8_t hashed[PGP_SHA1_HASH_SIZE];
|
||||
BIGNUM *tmp;
|
||||
|
||||
__OPS_USED(io);
|
||||
__PGP_USED(io);
|
||||
/* XXX - check for rsa/dsa */
|
||||
if (!openssl_read_pem_seckey(f, key, "ssh-rsa", 0)) {
|
||||
return 0;
|
||||
}
|
||||
if (__ops_get_debug_level(__FILE__)) {
|
||||
/*__ops_print_keydata(io, key, "sec", &key->key.seckey.pubkey, 0);*/
|
||||
if (pgp_get_debug_level(__FILE__)) {
|
||||
/*pgp_print_keydata(io, key, "sec", &key->key.seckey.pubkey, 0);*/
|
||||
/* XXX */
|
||||
}
|
||||
/* let's add some sane defaults */
|
||||
(void) memcpy(&key->key.seckey.pubkey, pubkey, sizeof(*pubkey));
|
||||
key->key.seckey.s2k_usage = OPS_S2KU_ENCRYPTED_AND_HASHED;
|
||||
key->key.seckey.alg = OPS_SA_CAST5;
|
||||
key->key.seckey.s2k_specifier = OPS_S2KS_SALTED;
|
||||
key->key.seckey.hash_alg = OPS_HASH_SHA1;
|
||||
if (key->key.seckey.pubkey.alg == OPS_PKA_RSA) {
|
||||
key->key.seckey.s2k_usage = PGP_S2KU_ENCRYPTED_AND_HASHED;
|
||||
key->key.seckey.alg = PGP_SA_CAST5;
|
||||
key->key.seckey.s2k_specifier = PGP_S2KS_SALTED;
|
||||
key->key.seckey.hash_alg = PGP_HASH_SHA1;
|
||||
if (key->key.seckey.pubkey.alg == PGP_PKA_RSA) {
|
||||
/* openssh and openssl have p and q swapped */
|
||||
tmp = key->key.seckey.key.rsa.p;
|
||||
key->key.seckey.key.rsa.p = key->key.seckey.key.rsa.q;
|
||||
@ -379,9 +379,9 @@ __ops_ssh2seckey(__ops_io_t *io, const char *f, __ops_key_t *key, __ops_pubkey_t
|
||||
int size;
|
||||
|
||||
needed = CAST_KEY_LENGTH - done;
|
||||
size = MIN(needed, OPS_SHA1_HASH_SIZE);
|
||||
size = MIN(needed, PGP_SHA1_HASH_SIZE);
|
||||
|
||||
__ops_hash_any(&hash, key->key.seckey.hash_alg);
|
||||
pgp_hash_any(&hash, key->key.seckey.hash_alg);
|
||||
if (!hash.init(&hash)) {
|
||||
(void) fprintf(stderr, "write_seckey_body: bad alloc\n");
|
||||
return 0;
|
||||
@ -399,8 +399,8 @@ __ops_ssh2seckey(__ops_io_t *io, const char *f, __ops_key_t *key, __ops_pubkey_t
|
||||
hash.add(&hash, &zero, 1);
|
||||
}
|
||||
|
||||
if (key->key.seckey.s2k_specifier == OPS_S2KS_SALTED) {
|
||||
hash.add(&hash, key->key.seckey.salt, OPS_SALT_SIZE);
|
||||
if (key->key.seckey.s2k_specifier == PGP_S2KS_SALTED) {
|
||||
hash.add(&hash, key->key.seckey.salt, PGP_SALT_SIZE);
|
||||
}
|
||||
hash.finish(&hash, hashed);
|
||||
|
||||
@ -408,7 +408,7 @@ __ops_ssh2seckey(__ops_io_t *io, const char *f, __ops_key_t *key, __ops_pubkey_t
|
||||
* if more in hash than is needed by session key, use
|
||||
* the leftmost octets
|
||||
*/
|
||||
(void) memcpy(&sesskey[i * OPS_SHA1_HASH_SIZE],
|
||||
(void) memcpy(&sesskey[i * PGP_SHA1_HASH_SIZE],
|
||||
hashed, (unsigned)size);
|
||||
done += (unsigned)size;
|
||||
if (done > CAST_KEY_LENGTH) {
|
||||
@ -417,56 +417,56 @@ __ops_ssh2seckey(__ops_io_t *io, const char *f, __ops_key_t *key, __ops_pubkey_t
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
__ops_crypt_any(&crypted, key->key.seckey.alg);
|
||||
pgp_crypt_any(&crypted, key->key.seckey.alg);
|
||||
crypted.set_iv(&crypted, key->key.seckey.iv);
|
||||
crypted.set_crypt_key(&crypted, sesskey);
|
||||
__ops_encrypt_init(&crypted);
|
||||
key->key.seckey.pubkey.alg = OPS_PKA_RSA;
|
||||
__ops_fingerprint(&key->sigfingerprint, pubkey, hashtype);
|
||||
__ops_keyid(key->sigid, sizeof(key->sigid), pubkey, hashtype);
|
||||
pgp_encrypt_init(&crypted);
|
||||
key->key.seckey.pubkey.alg = PGP_PKA_RSA;
|
||||
pgp_fingerprint(&key->sigfingerprint, pubkey, hashtype);
|
||||
pgp_keyid(key->sigid, sizeof(key->sigid), pubkey, hashtype);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* read a key from the ssh file, and add it to a keyring */
|
||||
int
|
||||
__ops_ssh2_readkeys(__ops_io_t *io, __ops_keyring_t *pubring,
|
||||
__ops_keyring_t *secring, const char *pubfile,
|
||||
pgp_ssh2_readkeys(pgp_io_t *io, pgp_keyring_t *pubring,
|
||||
pgp_keyring_t *secring, const char *pubfile,
|
||||
const char *secfile, unsigned hashtype)
|
||||
{
|
||||
__ops_key_t *pubkey;
|
||||
__ops_key_t *seckey;
|
||||
__ops_key_t key;
|
||||
pgp_key_t *pubkey;
|
||||
pgp_key_t *seckey;
|
||||
pgp_key_t key;
|
||||
|
||||
pubkey = NULL;
|
||||
(void) memset(&key, 0x0, sizeof(key));
|
||||
if (pubfile) {
|
||||
if (__ops_get_debug_level(__FILE__)) {
|
||||
(void) fprintf(io->errs, "__ops_ssh2_readkeys: pubfile '%s'\n", pubfile);
|
||||
if (pgp_get_debug_level(__FILE__)) {
|
||||
(void) fprintf(io->errs, "pgp_ssh2_readkeys: pubfile '%s'\n", pubfile);
|
||||
}
|
||||
if (!__ops_ssh2pubkey(io, pubfile, &key, (__ops_hash_alg_t)hashtype)) {
|
||||
(void) fprintf(io->errs, "__ops_ssh2_readkeys: can't read pubkeys '%s'\n", pubfile);
|
||||
if (!pgp_ssh2pubkey(io, pubfile, &key, (pgp_hash_alg_t)hashtype)) {
|
||||
(void) fprintf(io->errs, "pgp_ssh2_readkeys: can't read pubkeys '%s'\n", pubfile);
|
||||
return 0;
|
||||
}
|
||||
EXPAND_ARRAY(pubring, key);
|
||||
pubkey = &pubring->keys[pubring->keyc++];
|
||||
(void) memcpy(pubkey, &key, sizeof(key));
|
||||
pubkey->type = OPS_PTAG_CT_PUBLIC_KEY;
|
||||
pubkey->type = PGP_PTAG_CT_PUBLIC_KEY;
|
||||
}
|
||||
if (secfile) {
|
||||
if (__ops_get_debug_level(__FILE__)) {
|
||||
(void) fprintf(io->errs, "__ops_ssh2_readkeys: secfile '%s'\n", secfile);
|
||||
if (pgp_get_debug_level(__FILE__)) {
|
||||
(void) fprintf(io->errs, "pgp_ssh2_readkeys: secfile '%s'\n", secfile);
|
||||
}
|
||||
if (pubkey == NULL) {
|
||||
pubkey = &pubring->keys[0];
|
||||
}
|
||||
if (!__ops_ssh2seckey(io, secfile, &key, &pubkey->key.pubkey, (__ops_hash_alg_t)hashtype)) {
|
||||
(void) fprintf(io->errs, "__ops_ssh2_readkeys: can't read seckeys '%s'\n", secfile);
|
||||
if (!pgp_ssh2seckey(io, secfile, &key, &pubkey->key.pubkey, (pgp_hash_alg_t)hashtype)) {
|
||||
(void) fprintf(io->errs, "pgp_ssh2_readkeys: can't read seckeys '%s'\n", secfile);
|
||||
return 0;
|
||||
}
|
||||
EXPAND_ARRAY(secring, key);
|
||||
seckey = &secring->keys[secring->keyc++];
|
||||
(void) memcpy(seckey, &key, sizeof(key));
|
||||
seckey->type = OPS_PTAG_CT_SECRET_KEY;
|
||||
seckey->type = PGP_PTAG_CT_SECRET_KEY;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
162
crypto/external/bsd/netpgp/dist/src/lib/symmetric.c
vendored
162
crypto/external/bsd/netpgp/dist/src/lib/symmetric.c
vendored
@ -54,7 +54,7 @@
|
||||
|
||||
#if defined(__NetBSD__)
|
||||
__COPYRIGHT("@(#) Copyright (c) 2009 The NetBSD Foundation, Inc. All rights reserved.");
|
||||
__RCSID("$NetBSD: symmetric.c,v 1.17 2010/11/05 03:37:18 agc Exp $");
|
||||
__RCSID("$NetBSD: symmetric.c,v 1.18 2010/11/07 08:39:59 agc Exp $");
|
||||
#endif
|
||||
|
||||
#include "crypto.h"
|
||||
@ -87,20 +87,20 @@ __RCSID("$NetBSD: symmetric.c,v 1.17 2010/11/05 03:37:18 agc Exp $");
|
||||
|
||||
|
||||
static void
|
||||
std_set_iv(__ops_crypt_t *crypt, const uint8_t *iv)
|
||||
std_set_iv(pgp_crypt_t *crypt, const uint8_t *iv)
|
||||
{
|
||||
(void) memcpy(crypt->iv, iv, crypt->blocksize);
|
||||
crypt->num = 0;
|
||||
}
|
||||
|
||||
static void
|
||||
std_set_key(__ops_crypt_t *crypt, const uint8_t *key)
|
||||
std_set_key(pgp_crypt_t *crypt, const uint8_t *key)
|
||||
{
|
||||
(void) memcpy(crypt->key, key, crypt->keysize);
|
||||
}
|
||||
|
||||
static void
|
||||
std_resync(__ops_crypt_t *decrypt)
|
||||
std_resync(pgp_crypt_t *decrypt)
|
||||
{
|
||||
if ((size_t) decrypt->num == decrypt->blocksize) {
|
||||
return;
|
||||
@ -114,7 +114,7 @@ std_resync(__ops_crypt_t *decrypt)
|
||||
}
|
||||
|
||||
static void
|
||||
std_finish(__ops_crypt_t *crypt)
|
||||
std_finish(pgp_crypt_t *crypt)
|
||||
{
|
||||
if (crypt->encrypt_key) {
|
||||
free(crypt->encrypt_key);
|
||||
@ -127,7 +127,7 @@ std_finish(__ops_crypt_t *crypt)
|
||||
}
|
||||
|
||||
static int
|
||||
cast5_init(__ops_crypt_t *crypt)
|
||||
cast5_init(pgp_crypt_t *crypt)
|
||||
{
|
||||
if (crypt->encrypt_key) {
|
||||
free(crypt->encrypt_key);
|
||||
@ -146,19 +146,19 @@ cast5_init(__ops_crypt_t *crypt)
|
||||
}
|
||||
|
||||
static void
|
||||
cast5_block_encrypt(__ops_crypt_t *crypt, void *out, const void *in)
|
||||
cast5_block_encrypt(pgp_crypt_t *crypt, void *out, const void *in)
|
||||
{
|
||||
CAST_ecb_encrypt(in, out, crypt->encrypt_key, CAST_ENCRYPT);
|
||||
}
|
||||
|
||||
static void
|
||||
cast5_block_decrypt(__ops_crypt_t *crypt, void *out, const void *in)
|
||||
cast5_block_decrypt(pgp_crypt_t *crypt, void *out, const void *in)
|
||||
{
|
||||
CAST_ecb_encrypt(in, out, crypt->encrypt_key, CAST_DECRYPT);
|
||||
}
|
||||
|
||||
static void
|
||||
cast5_cfb_encrypt(__ops_crypt_t *crypt, void *out, const void *in, size_t count)
|
||||
cast5_cfb_encrypt(pgp_crypt_t *crypt, void *out, const void *in, size_t count)
|
||||
{
|
||||
CAST_cfb64_encrypt(in, out, (long)count,
|
||||
crypt->encrypt_key, crypt->iv, &crypt->num,
|
||||
@ -166,7 +166,7 @@ cast5_cfb_encrypt(__ops_crypt_t *crypt, void *out, const void *in, size_t count)
|
||||
}
|
||||
|
||||
static void
|
||||
cast5_cfb_decrypt(__ops_crypt_t *crypt, void *out, const void *in, size_t count)
|
||||
cast5_cfb_decrypt(pgp_crypt_t *crypt, void *out, const void *in, size_t count)
|
||||
{
|
||||
CAST_cfb64_encrypt(in, out, (long)count,
|
||||
crypt->encrypt_key, crypt->iv, &crypt->num,
|
||||
@ -175,9 +175,9 @@ cast5_cfb_decrypt(__ops_crypt_t *crypt, void *out, const void *in, size_t count)
|
||||
|
||||
#define TRAILER "","","","",0,NULL,NULL
|
||||
|
||||
static __ops_crypt_t cast5 =
|
||||
static pgp_crypt_t cast5 =
|
||||
{
|
||||
OPS_SA_CAST5,
|
||||
PGP_SA_CAST5,
|
||||
CAST_BLOCK,
|
||||
CAST_KEY_LENGTH,
|
||||
std_set_iv,
|
||||
@ -194,7 +194,7 @@ static __ops_crypt_t cast5 =
|
||||
|
||||
#ifndef OPENSSL_NO_IDEA
|
||||
static int
|
||||
idea_init(__ops_crypt_t *crypt)
|
||||
idea_init(pgp_crypt_t *crypt)
|
||||
{
|
||||
if (crypt->keysize != IDEA_KEY_LENGTH) {
|
||||
(void) fprintf(stderr, "idea_init: keysize wrong\n");
|
||||
@ -225,19 +225,19 @@ idea_init(__ops_crypt_t *crypt)
|
||||
}
|
||||
|
||||
static void
|
||||
idea_block_encrypt(__ops_crypt_t *crypt, void *out, const void *in)
|
||||
idea_block_encrypt(pgp_crypt_t *crypt, void *out, const void *in)
|
||||
{
|
||||
idea_ecb_encrypt(in, out, crypt->encrypt_key);
|
||||
}
|
||||
|
||||
static void
|
||||
idea_block_decrypt(__ops_crypt_t *crypt, void *out, const void *in)
|
||||
idea_block_decrypt(pgp_crypt_t *crypt, void *out, const void *in)
|
||||
{
|
||||
idea_ecb_encrypt(in, out, crypt->decrypt_key);
|
||||
}
|
||||
|
||||
static void
|
||||
idea_cfb_encrypt(__ops_crypt_t *crypt, void *out, const void *in, size_t count)
|
||||
idea_cfb_encrypt(pgp_crypt_t *crypt, void *out, const void *in, size_t count)
|
||||
{
|
||||
idea_cfb64_encrypt(in, out, (long)count,
|
||||
crypt->encrypt_key, crypt->iv, &crypt->num,
|
||||
@ -245,16 +245,16 @@ idea_cfb_encrypt(__ops_crypt_t *crypt, void *out, const void *in, size_t count)
|
||||
}
|
||||
|
||||
static void
|
||||
idea_cfb_decrypt(__ops_crypt_t *crypt, void *out, const void *in, size_t count)
|
||||
idea_cfb_decrypt(pgp_crypt_t *crypt, void *out, const void *in, size_t count)
|
||||
{
|
||||
idea_cfb64_encrypt(in, out, (long)count,
|
||||
crypt->decrypt_key, crypt->iv, &crypt->num,
|
||||
CAST_DECRYPT);
|
||||
}
|
||||
|
||||
static const __ops_crypt_t idea =
|
||||
static const pgp_crypt_t idea =
|
||||
{
|
||||
OPS_SA_IDEA,
|
||||
PGP_SA_IDEA,
|
||||
IDEA_BLOCK,
|
||||
IDEA_KEY_LENGTH,
|
||||
std_set_iv,
|
||||
@ -275,7 +275,7 @@ static const __ops_crypt_t idea =
|
||||
#define KEYBITS_AES128 128
|
||||
|
||||
static int
|
||||
aes128_init(__ops_crypt_t *crypt)
|
||||
aes128_init(pgp_crypt_t *crypt)
|
||||
{
|
||||
if (crypt->encrypt_key) {
|
||||
free(crypt->encrypt_key);
|
||||
@ -304,19 +304,19 @@ aes128_init(__ops_crypt_t *crypt)
|
||||
}
|
||||
|
||||
static void
|
||||
aes_block_encrypt(__ops_crypt_t *crypt, void *out, const void *in)
|
||||
aes_block_encrypt(pgp_crypt_t *crypt, void *out, const void *in)
|
||||
{
|
||||
AES_encrypt(in, out, crypt->encrypt_key);
|
||||
}
|
||||
|
||||
static void
|
||||
aes_block_decrypt(__ops_crypt_t *crypt, void *out, const void *in)
|
||||
aes_block_decrypt(pgp_crypt_t *crypt, void *out, const void *in)
|
||||
{
|
||||
AES_decrypt(in, out, crypt->decrypt_key);
|
||||
}
|
||||
|
||||
static void
|
||||
aes_cfb_encrypt(__ops_crypt_t *crypt, void *out, const void *in, size_t count)
|
||||
aes_cfb_encrypt(pgp_crypt_t *crypt, void *out, const void *in, size_t count)
|
||||
{
|
||||
AES_cfb128_encrypt(in, out, (unsigned)count,
|
||||
crypt->encrypt_key, crypt->iv, &crypt->num,
|
||||
@ -324,16 +324,16 @@ aes_cfb_encrypt(__ops_crypt_t *crypt, void *out, const void *in, size_t count)
|
||||
}
|
||||
|
||||
static void
|
||||
aes_cfb_decrypt(__ops_crypt_t *crypt, void *out, const void *in, size_t count)
|
||||
aes_cfb_decrypt(pgp_crypt_t *crypt, void *out, const void *in, size_t count)
|
||||
{
|
||||
AES_cfb128_encrypt(in, out, (unsigned)count,
|
||||
crypt->encrypt_key, crypt->iv, &crypt->num,
|
||||
AES_DECRYPT);
|
||||
}
|
||||
|
||||
static const __ops_crypt_t aes128 =
|
||||
static const pgp_crypt_t aes128 =
|
||||
{
|
||||
OPS_SA_AES_128,
|
||||
PGP_SA_AES_128,
|
||||
AES_BLOCK_SIZE,
|
||||
KEYBITS_AES128 / 8,
|
||||
std_set_iv,
|
||||
@ -353,7 +353,7 @@ static const __ops_crypt_t aes128 =
|
||||
#define KEYBITS_AES256 256
|
||||
|
||||
static int
|
||||
aes256_init(__ops_crypt_t *crypt)
|
||||
aes256_init(pgp_crypt_t *crypt)
|
||||
{
|
||||
if (crypt->encrypt_key) {
|
||||
free(crypt->encrypt_key);
|
||||
@ -390,9 +390,9 @@ aes256_init(__ops_crypt_t *crypt)
|
||||
return 1;
|
||||
}
|
||||
|
||||
static const __ops_crypt_t aes256 =
|
||||
static const pgp_crypt_t aes256 =
|
||||
{
|
||||
OPS_SA_AES_256,
|
||||
PGP_SA_AES_256,
|
||||
AES_BLOCK_SIZE,
|
||||
KEYBITS_AES256 / 8,
|
||||
std_set_iv,
|
||||
@ -410,7 +410,7 @@ static const __ops_crypt_t aes256 =
|
||||
/* Triple DES */
|
||||
|
||||
static int
|
||||
tripledes_init(__ops_crypt_t *crypt)
|
||||
tripledes_init(pgp_crypt_t *crypt)
|
||||
{
|
||||
DES_key_schedule *keys;
|
||||
int n;
|
||||
@ -430,7 +430,7 @@ tripledes_init(__ops_crypt_t *crypt)
|
||||
}
|
||||
|
||||
static void
|
||||
tripledes_block_encrypt(__ops_crypt_t *crypt, void *out, const void *in)
|
||||
tripledes_block_encrypt(pgp_crypt_t *crypt, void *out, const void *in)
|
||||
{
|
||||
DES_key_schedule *keys = crypt->encrypt_key;
|
||||
|
||||
@ -439,7 +439,7 @@ tripledes_block_encrypt(__ops_crypt_t *crypt, void *out, const void *in)
|
||||
}
|
||||
|
||||
static void
|
||||
tripledes_block_decrypt(__ops_crypt_t *crypt, void *out, const void *in)
|
||||
tripledes_block_decrypt(pgp_crypt_t *crypt, void *out, const void *in)
|
||||
{
|
||||
DES_key_schedule *keys = crypt->encrypt_key;
|
||||
|
||||
@ -448,7 +448,7 @@ tripledes_block_decrypt(__ops_crypt_t *crypt, void *out, const void *in)
|
||||
}
|
||||
|
||||
static void
|
||||
tripledes_cfb_encrypt(__ops_crypt_t *crypt, void *out, const void *in,
|
||||
tripledes_cfb_encrypt(pgp_crypt_t *crypt, void *out, const void *in,
|
||||
size_t count)
|
||||
{
|
||||
DES_key_schedule *keys = crypt->encrypt_key;
|
||||
@ -459,7 +459,7 @@ tripledes_cfb_encrypt(__ops_crypt_t *crypt, void *out, const void *in,
|
||||
}
|
||||
|
||||
static void
|
||||
tripledes_cfb_decrypt(__ops_crypt_t *crypt, void *out, const void *in,
|
||||
tripledes_cfb_decrypt(pgp_crypt_t *crypt, void *out, const void *in,
|
||||
size_t count)
|
||||
{
|
||||
DES_key_schedule *keys = crypt->encrypt_key;
|
||||
@ -469,9 +469,9 @@ tripledes_cfb_decrypt(__ops_crypt_t *crypt, void *out, const void *in,
|
||||
&crypt->num, DES_DECRYPT);
|
||||
}
|
||||
|
||||
static const __ops_crypt_t tripledes =
|
||||
static const pgp_crypt_t tripledes =
|
||||
{
|
||||
OPS_SA_TRIPLEDES,
|
||||
PGP_SA_TRIPLEDES,
|
||||
8,
|
||||
24,
|
||||
std_set_iv,
|
||||
@ -492,7 +492,7 @@ static const __ops_crypt_t tripledes =
|
||||
#define KEYBITS_CAMELLIA128 128
|
||||
|
||||
static int
|
||||
camellia128_init(__ops_crypt_t *crypt)
|
||||
camellia128_init(pgp_crypt_t *crypt)
|
||||
{
|
||||
if (crypt->encrypt_key) {
|
||||
free(crypt->encrypt_key);
|
||||
@ -518,19 +518,19 @@ camellia128_init(__ops_crypt_t *crypt)
|
||||
}
|
||||
|
||||
static void
|
||||
camellia_block_encrypt(__ops_crypt_t *crypt, void *out, const void *in)
|
||||
camellia_block_encrypt(pgp_crypt_t *crypt, void *out, const void *in)
|
||||
{
|
||||
Camellia_encrypt(in, out, crypt->encrypt_key);
|
||||
}
|
||||
|
||||
static void
|
||||
camellia_block_decrypt(__ops_crypt_t *crypt, void *out, const void *in)
|
||||
camellia_block_decrypt(pgp_crypt_t *crypt, void *out, const void *in)
|
||||
{
|
||||
Camellia_decrypt(in, out, crypt->decrypt_key);
|
||||
}
|
||||
|
||||
static void
|
||||
camellia_cfb_encrypt(__ops_crypt_t *crypt, void *out, const void *in, size_t count)
|
||||
camellia_cfb_encrypt(pgp_crypt_t *crypt, void *out, const void *in, size_t count)
|
||||
{
|
||||
Camellia_cfb128_encrypt(in, out, (unsigned)count,
|
||||
crypt->encrypt_key, crypt->iv, &crypt->num,
|
||||
@ -538,16 +538,16 @@ camellia_cfb_encrypt(__ops_crypt_t *crypt, void *out, const void *in, size_t cou
|
||||
}
|
||||
|
||||
static void
|
||||
camellia_cfb_decrypt(__ops_crypt_t *crypt, void *out, const void *in, size_t count)
|
||||
camellia_cfb_decrypt(pgp_crypt_t *crypt, void *out, const void *in, size_t count)
|
||||
{
|
||||
Camellia_cfb128_encrypt(in, out, (unsigned)count,
|
||||
crypt->encrypt_key, crypt->iv, &crypt->num,
|
||||
CAMELLIA_DECRYPT);
|
||||
}
|
||||
|
||||
static const __ops_crypt_t camellia128 =
|
||||
static const pgp_crypt_t camellia128 =
|
||||
{
|
||||
OPS_SA_CAMELLIA_128,
|
||||
PGP_SA_CAMELLIA_128,
|
||||
CAMELLIA_BLOCK_SIZE,
|
||||
KEYBITS_CAMELLIA128 / 8,
|
||||
std_set_iv,
|
||||
@ -567,7 +567,7 @@ static const __ops_crypt_t camellia128 =
|
||||
#define KEYBITS_CAMELLIA256 256
|
||||
|
||||
static int
|
||||
camellia256_init(__ops_crypt_t *crypt)
|
||||
camellia256_init(pgp_crypt_t *crypt)
|
||||
{
|
||||
if (crypt->encrypt_key) {
|
||||
free(crypt->encrypt_key);
|
||||
@ -592,9 +592,9 @@ camellia256_init(__ops_crypt_t *crypt)
|
||||
return 1;
|
||||
}
|
||||
|
||||
static const __ops_crypt_t camellia256 =
|
||||
static const pgp_crypt_t camellia256 =
|
||||
{
|
||||
OPS_SA_CAMELLIA_256,
|
||||
PGP_SA_CAMELLIA_256,
|
||||
CAMELLIA_BLOCK_SIZE,
|
||||
KEYBITS_CAMELLIA256 / 8,
|
||||
std_set_iv,
|
||||
@ -611,39 +611,39 @@ static const __ops_crypt_t camellia256 =
|
||||
#endif
|
||||
|
||||
|
||||
static const __ops_crypt_t *
|
||||
get_proto(__ops_symm_alg_t alg)
|
||||
static const pgp_crypt_t *
|
||||
get_proto(pgp_symm_alg_t alg)
|
||||
{
|
||||
switch (alg) {
|
||||
case OPS_SA_CAST5:
|
||||
case PGP_SA_CAST5:
|
||||
return &cast5;
|
||||
#ifndef OPENSSL_NO_IDEA
|
||||
case OPS_SA_IDEA:
|
||||
case PGP_SA_IDEA:
|
||||
return &idea;
|
||||
#endif /* OPENSSL_NO_IDEA */
|
||||
case OPS_SA_AES_128:
|
||||
case PGP_SA_AES_128:
|
||||
return &aes128;
|
||||
case OPS_SA_AES_256:
|
||||
case PGP_SA_AES_256:
|
||||
return &aes256;
|
||||
#if defined(HAVE_OPENSSL_CAMELLIA_H) && !defined(OPENSSL_NO_CAMELLIA)
|
||||
case OPS_SA_CAMELLIA_128:
|
||||
case PGP_SA_CAMELLIA_128:
|
||||
return &camellia128;
|
||||
case OPS_SA_CAMELLIA_256:
|
||||
case PGP_SA_CAMELLIA_256:
|
||||
return &camellia256;
|
||||
#endif
|
||||
case OPS_SA_TRIPLEDES:
|
||||
case PGP_SA_TRIPLEDES:
|
||||
return &tripledes;
|
||||
default:
|
||||
(void) fprintf(stderr, "Unknown algorithm: %d (%s)\n",
|
||||
alg, __ops_show_symm_alg(alg));
|
||||
alg, pgp_show_symm_alg(alg));
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int
|
||||
__ops_crypt_any(__ops_crypt_t *crypt, __ops_symm_alg_t alg)
|
||||
pgp_crypt_any(pgp_crypt_t *crypt, pgp_symm_alg_t alg)
|
||||
{
|
||||
const __ops_crypt_t *ptr = get_proto(alg);
|
||||
const pgp_crypt_t *ptr = get_proto(alg);
|
||||
|
||||
if (ptr) {
|
||||
*crypt = *ptr;
|
||||
@ -655,30 +655,30 @@ __ops_crypt_any(__ops_crypt_t *crypt, __ops_symm_alg_t alg)
|
||||
}
|
||||
|
||||
unsigned
|
||||
__ops_block_size(__ops_symm_alg_t alg)
|
||||
pgp_block_size(pgp_symm_alg_t alg)
|
||||
{
|
||||
const __ops_crypt_t *p = get_proto(alg);
|
||||
const pgp_crypt_t *p = get_proto(alg);
|
||||
|
||||
return (p == NULL) ? 0 : (unsigned)p->blocksize;
|
||||
}
|
||||
|
||||
unsigned
|
||||
__ops_key_size(__ops_symm_alg_t alg)
|
||||
pgp_key_size(pgp_symm_alg_t alg)
|
||||
{
|
||||
const __ops_crypt_t *p = get_proto(alg);
|
||||
const pgp_crypt_t *p = get_proto(alg);
|
||||
|
||||
return (p == NULL) ? 0 : (unsigned)p->keysize;
|
||||
}
|
||||
|
||||
void
|
||||
__ops_encrypt_init(__ops_crypt_t *encrypt)
|
||||
pgp_encrypt_init(pgp_crypt_t *encrypt)
|
||||
{
|
||||
/* \todo should there be a separate __ops_encrypt_init? */
|
||||
__ops_decrypt_init(encrypt);
|
||||
/* \todo should there be a separate pgp_encrypt_init? */
|
||||
pgp_decrypt_init(encrypt);
|
||||
}
|
||||
|
||||
void
|
||||
__ops_decrypt_init(__ops_crypt_t *decrypt)
|
||||
pgp_decrypt_init(pgp_crypt_t *decrypt)
|
||||
{
|
||||
decrypt->base_init(decrypt);
|
||||
decrypt->block_encrypt(decrypt, decrypt->siv, decrypt->iv);
|
||||
@ -687,7 +687,7 @@ __ops_decrypt_init(__ops_crypt_t *decrypt)
|
||||
}
|
||||
|
||||
size_t
|
||||
__ops_decrypt_se(__ops_crypt_t *decrypt, void *outvoid, const void *invoid,
|
||||
pgp_decrypt_se(pgp_crypt_t *decrypt, void *outvoid, const void *invoid,
|
||||
size_t count)
|
||||
{
|
||||
const uint8_t *in = invoid;
|
||||
@ -716,7 +716,7 @@ __ops_decrypt_se(__ops_crypt_t *decrypt, void *outvoid, const void *invoid,
|
||||
}
|
||||
|
||||
size_t
|
||||
__ops_encrypt_se(__ops_crypt_t *encrypt, void *outvoid, const void *invoid,
|
||||
pgp_encrypt_se(pgp_crypt_t *encrypt, void *outvoid, const void *invoid,
|
||||
size_t count)
|
||||
{
|
||||
const uint8_t *in = invoid;
|
||||
@ -750,34 +750,34 @@ __ops_encrypt_se(__ops_crypt_t *encrypt, void *outvoid, const void *invoid,
|
||||
\return 1 if supported; else 0
|
||||
*/
|
||||
unsigned
|
||||
__ops_is_sa_supported(__ops_symm_alg_t alg)
|
||||
pgp_is_sa_supported(pgp_symm_alg_t alg)
|
||||
{
|
||||
switch (alg) {
|
||||
case OPS_SA_AES_128:
|
||||
case OPS_SA_AES_256:
|
||||
case OPS_SA_CAST5:
|
||||
case OPS_SA_TRIPLEDES:
|
||||
case PGP_SA_AES_128:
|
||||
case PGP_SA_AES_256:
|
||||
case PGP_SA_CAST5:
|
||||
case PGP_SA_TRIPLEDES:
|
||||
#if defined(HAVE_OPENSSL_CAMELLIA_H) && !defined(OPENSSL_NO_CAMELLIA)
|
||||
case OPS_SA_CAMELLIA_128:
|
||||
case OPS_SA_CAMELLIA_256:
|
||||
case PGP_SA_CAMELLIA_128:
|
||||
case PGP_SA_CAMELLIA_256:
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_IDEA
|
||||
case OPS_SA_IDEA:
|
||||
case PGP_SA_IDEA:
|
||||
#endif
|
||||
return 1;
|
||||
|
||||
default:
|
||||
fprintf(stderr, "\nWarning: %s not supported\n",
|
||||
__ops_show_symm_alg(alg));
|
||||
pgp_show_symm_alg(alg));
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
size_t
|
||||
__ops_encrypt_se_ip(__ops_crypt_t *crypt, void *out, const void *in,
|
||||
pgp_encrypt_se_ip(pgp_crypt_t *crypt, void *out, const void *in,
|
||||
size_t count)
|
||||
{
|
||||
if (!__ops_is_sa_supported(crypt->alg)) {
|
||||
if (!pgp_is_sa_supported(crypt->alg)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -788,10 +788,10 @@ __ops_encrypt_se_ip(__ops_crypt_t *crypt, void *out, const void *in,
|
||||
}
|
||||
|
||||
size_t
|
||||
__ops_decrypt_se_ip(__ops_crypt_t *crypt, void *out, const void *in,
|
||||
pgp_decrypt_se_ip(pgp_crypt_t *crypt, void *out, const void *in,
|
||||
size_t count)
|
||||
{
|
||||
if (!__ops_is_sa_supported(crypt->alg)) {
|
||||
if (!pgp_is_sa_supported(crypt->alg)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
30
crypto/external/bsd/netpgp/dist/src/lib/types.h
vendored
30
crypto/external/bsd/netpgp/dist/src/lib/types.h
vendored
@ -53,42 +53,42 @@
|
||||
#include <inttypes.h>
|
||||
#endif
|
||||
|
||||
typedef struct __ops_io_t {
|
||||
typedef struct pgp_io_t {
|
||||
void *outs; /* output file stream */
|
||||
void *errs; /* file stream to put error messages */
|
||||
void *res; /* file stream to put results */
|
||||
} __ops_io_t;
|
||||
} pgp_io_t;
|
||||
|
||||
/** __ops_map_t
|
||||
/** pgp_map_t
|
||||
*/
|
||||
typedef struct {
|
||||
int type;
|
||||
const char *string;
|
||||
} __ops_map_t;
|
||||
} pgp_map_t;
|
||||
|
||||
/** __ops_errcode_name_map_t */
|
||||
typedef __ops_map_t __ops_errcode_name_map_t;
|
||||
/** pgp_errcode_name_map_t */
|
||||
typedef pgp_map_t pgp_errcode_name_map_t;
|
||||
|
||||
typedef struct _ops_crypt_t __ops_crypt_t;
|
||||
typedef struct _ops_crypt_t pgp_crypt_t;
|
||||
|
||||
/** __ops_hash_t */
|
||||
typedef struct _ops_hash_t __ops_hash_t;
|
||||
/** pgp_hash_t */
|
||||
typedef struct _ops_hash_t pgp_hash_t;
|
||||
|
||||
/** Revocation Reason type */
|
||||
typedef uint8_t __ops_ss_rr_code_t;
|
||||
typedef uint8_t pgp_ss_rr_code_t;
|
||||
|
||||
/** __ops_packet_t */
|
||||
typedef struct __ops_packet_t __ops_packet_t;
|
||||
/** pgp_packet_t */
|
||||
typedef struct pgp_packet_t pgp_packet_t;
|
||||
|
||||
/** Writer flags */
|
||||
typedef enum {
|
||||
OPS_WF_DUMMY
|
||||
} __ops_writer_flags_t;
|
||||
PGP_WF_DUMMY
|
||||
} pgp_writer_flags_t;
|
||||
|
||||
/**
|
||||
* \ingroup Create
|
||||
* Contains the required information about how to write
|
||||
*/
|
||||
typedef struct __ops_output_t __ops_output_t;
|
||||
typedef struct pgp_output_t pgp_output_t;
|
||||
|
||||
#endif /* TYPES_H_ */
|
||||
|
402
crypto/external/bsd/netpgp/dist/src/lib/validate.c
vendored
402
crypto/external/bsd/netpgp/dist/src/lib/validate.c
vendored
@ -54,7 +54,7 @@
|
||||
|
||||
#if defined(__NetBSD__)
|
||||
__COPYRIGHT("@(#) Copyright (c) 2009 The NetBSD Foundation, Inc. All rights reserved.");
|
||||
__RCSID("$NetBSD: validate.c,v 1.41 2010/11/04 16:24:22 agc Exp $");
|
||||
__RCSID("$NetBSD: validate.c,v 1.42 2010/11/07 08:39:59 agc Exp $");
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
@ -90,14 +90,14 @@ __RCSID("$NetBSD: validate.c,v 1.41 2010/11/04 16:24:22 agc Exp $");
|
||||
|
||||
|
||||
static int
|
||||
keydata_reader(void *dest, size_t length, __ops_error_t **errors,
|
||||
__ops_reader_t *readinfo,
|
||||
__ops_cbdata_t *cbinfo)
|
||||
keydata_reader(void *dest, size_t length, pgp_error_t **errors,
|
||||
pgp_reader_t *readinfo,
|
||||
pgp_cbdata_t *cbinfo)
|
||||
{
|
||||
validate_reader_t *reader = __ops_reader_get_arg(readinfo);
|
||||
validate_reader_t *reader = pgp_reader_get_arg(readinfo);
|
||||
|
||||
__OPS_USED(errors);
|
||||
__OPS_USED(cbinfo);
|
||||
__PGP_USED(errors);
|
||||
__PGP_USED(cbinfo);
|
||||
if (reader->offset == reader->key->packets[reader->packet].length) {
|
||||
reader->packet += 1;
|
||||
reader->offset = 0;
|
||||
@ -125,14 +125,14 @@ keydata_reader(void *dest, size_t length, __ops_error_t **errors,
|
||||
}
|
||||
|
||||
static void
|
||||
free_sig_info(__ops_sig_info_t *sig)
|
||||
free_sig_info(pgp_sig_info_t *sig)
|
||||
{
|
||||
free(sig->v4_hashed);
|
||||
free(sig);
|
||||
}
|
||||
|
||||
static void
|
||||
copy_sig_info(__ops_sig_info_t *dst, const __ops_sig_info_t *src)
|
||||
copy_sig_info(pgp_sig_info_t *dst, const pgp_sig_info_t *src)
|
||||
{
|
||||
(void) memcpy(dst, src, sizeof(*src));
|
||||
if ((dst->v4_hashed = calloc(1, src->v4_hashlen)) == NULL) {
|
||||
@ -143,16 +143,16 @@ copy_sig_info(__ops_sig_info_t *dst, const __ops_sig_info_t *src)
|
||||
}
|
||||
|
||||
static int
|
||||
add_sig_to_list(const __ops_sig_info_t *sig, __ops_sig_info_t **sigs,
|
||||
add_sig_to_list(const pgp_sig_info_t *sig, pgp_sig_info_t **sigs,
|
||||
unsigned *count)
|
||||
{
|
||||
__ops_sig_info_t *newsigs;
|
||||
pgp_sig_info_t *newsigs;
|
||||
|
||||
if (*count == 0) {
|
||||
newsigs = calloc(*count + 1, sizeof(__ops_sig_info_t));
|
||||
newsigs = calloc(*count + 1, sizeof(pgp_sig_info_t));
|
||||
} else {
|
||||
newsigs = realloc(*sigs,
|
||||
(*count + 1) * sizeof(__ops_sig_info_t));
|
||||
(*count + 1) * sizeof(pgp_sig_info_t));
|
||||
}
|
||||
if (newsigs == NULL) {
|
||||
(void) fprintf(stderr, "add_sig_to_list: alloc failure\n");
|
||||
@ -169,7 +169,7 @@ The hash value is calculated by the following method:
|
||||
+ hash the data using the given digest algorithm
|
||||
+ hash the hash value onto the end
|
||||
+ hash the trailer - 6 bytes
|
||||
[OPS_V4][0xff][len >> 24][len >> 16][len >> 8][len & 0xff]
|
||||
[PGP_V4][0xff][len >> 24][len >> 16][len >> 8][len & 0xff]
|
||||
to give the final hash value that is checked against the one in the signature
|
||||
*/
|
||||
|
||||
@ -177,23 +177,23 @@ to give the final hash value that is checked against the one in the signature
|
||||
unsigned
|
||||
check_binary_sig(const uint8_t *data,
|
||||
const unsigned len,
|
||||
const __ops_sig_t *sig,
|
||||
const __ops_pubkey_t *signer)
|
||||
const pgp_sig_t *sig,
|
||||
const pgp_pubkey_t *signer)
|
||||
{
|
||||
unsigned hashedlen;
|
||||
__ops_hash_t hash;
|
||||
pgp_hash_t hash;
|
||||
unsigned n;
|
||||
uint8_t hashout[OPS_MAX_HASH_SIZE];
|
||||
uint8_t hashout[PGP_MAX_HASH_SIZE];
|
||||
uint8_t trailer[6];
|
||||
|
||||
__ops_hash_any(&hash, sig->info.hash_alg);
|
||||
pgp_hash_any(&hash, sig->info.hash_alg);
|
||||
if (!hash.init(&hash)) {
|
||||
(void) fprintf(stderr, "check_binary_sig: bad hash init\n");
|
||||
return 0;
|
||||
}
|
||||
hash.add(&hash, data, len);
|
||||
switch (sig->info.version) {
|
||||
case OPS_V3:
|
||||
case PGP_V3:
|
||||
trailer[0] = sig->info.type;
|
||||
trailer[1] = (unsigned)(sig->info.birthtime) >> 24;
|
||||
trailer[2] = (unsigned)(sig->info.birthtime) >> 16;
|
||||
@ -202,8 +202,8 @@ check_binary_sig(const uint8_t *data,
|
||||
hash.add(&hash, trailer, 5);
|
||||
break;
|
||||
|
||||
case OPS_V4:
|
||||
if (__ops_get_debug_level(__FILE__)) {
|
||||
case PGP_V4:
|
||||
if (pgp_get_debug_level(__FILE__)) {
|
||||
hexdump(stderr, "v4 hash", sig->info.v4_hashed,
|
||||
sig->info.v4_hashlen);
|
||||
}
|
||||
@ -225,80 +225,80 @@ check_binary_sig(const uint8_t *data,
|
||||
}
|
||||
|
||||
n = hash.finish(&hash, hashout);
|
||||
if (__ops_get_debug_level(__FILE__)) {
|
||||
if (pgp_get_debug_level(__FILE__)) {
|
||||
hexdump(stdout, "hash out", hashout, n);
|
||||
}
|
||||
return __ops_check_sig(hashout, n, sig, signer);
|
||||
return pgp_check_sig(hashout, n, sig, signer);
|
||||
}
|
||||
|
||||
__ops_cb_ret_t
|
||||
__ops_validate_key_cb(const __ops_packet_t *pkt, __ops_cbdata_t *cbinfo)
|
||||
pgp_cb_ret_t
|
||||
pgp_validate_key_cb(const pgp_packet_t *pkt, pgp_cbdata_t *cbinfo)
|
||||
{
|
||||
const __ops_contents_t *content = &pkt->u;
|
||||
const __ops_key_t *signer;
|
||||
const pgp_contents_t *content = &pkt->u;
|
||||
const pgp_key_t *signer;
|
||||
validate_key_cb_t *key;
|
||||
__ops_pubkey_t *sigkey;
|
||||
__ops_error_t **errors;
|
||||
__ops_io_t *io;
|
||||
pgp_pubkey_t *sigkey;
|
||||
pgp_error_t **errors;
|
||||
pgp_io_t *io;
|
||||
unsigned from;
|
||||
unsigned valid = 0;
|
||||
|
||||
io = cbinfo->io;
|
||||
if (__ops_get_debug_level(__FILE__)) {
|
||||
if (pgp_get_debug_level(__FILE__)) {
|
||||
(void) fprintf(io->errs, "%s\n",
|
||||
__ops_show_packet_tag(pkt->tag));
|
||||
pgp_show_packet_tag(pkt->tag));
|
||||
}
|
||||
key = __ops_callback_arg(cbinfo);
|
||||
errors = __ops_callback_errors(cbinfo);
|
||||
key = pgp_callback_arg(cbinfo);
|
||||
errors = pgp_callback_errors(cbinfo);
|
||||
switch (pkt->tag) {
|
||||
case OPS_PTAG_CT_PUBLIC_KEY:
|
||||
case PGP_PTAG_CT_PUBLIC_KEY:
|
||||
if (key->pubkey.version != 0) {
|
||||
(void) fprintf(io->errs,
|
||||
"__ops_validate_key_cb: version bad\n");
|
||||
return OPS_FINISHED;
|
||||
"pgp_validate_key_cb: version bad\n");
|
||||
return PGP_FINISHED;
|
||||
}
|
||||
key->pubkey = content->pubkey;
|
||||
return OPS_KEEP_MEMORY;
|
||||
return PGP_KEEP_MEMORY;
|
||||
|
||||
case OPS_PTAG_CT_PUBLIC_SUBKEY:
|
||||
case PGP_PTAG_CT_PUBLIC_SUBKEY:
|
||||
if (key->subkey.version) {
|
||||
__ops_pubkey_free(&key->subkey);
|
||||
pgp_pubkey_free(&key->subkey);
|
||||
}
|
||||
key->subkey = content->pubkey;
|
||||
return OPS_KEEP_MEMORY;
|
||||
return PGP_KEEP_MEMORY;
|
||||
|
||||
case OPS_PTAG_CT_SECRET_KEY:
|
||||
case PGP_PTAG_CT_SECRET_KEY:
|
||||
key->seckey = content->seckey;
|
||||
key->pubkey = key->seckey.pubkey;
|
||||
return OPS_KEEP_MEMORY;
|
||||
return PGP_KEEP_MEMORY;
|
||||
|
||||
case OPS_PTAG_CT_USER_ID:
|
||||
case PGP_PTAG_CT_USER_ID:
|
||||
if (key->userid) {
|
||||
__ops_userid_free(&key->userid);
|
||||
pgp_userid_free(&key->userid);
|
||||
}
|
||||
key->userid = content->userid;
|
||||
key->last_seen = ID;
|
||||
return OPS_KEEP_MEMORY;
|
||||
return PGP_KEEP_MEMORY;
|
||||
|
||||
case OPS_PTAG_CT_USER_ATTR:
|
||||
case PGP_PTAG_CT_USER_ATTR:
|
||||
if (content->userattr.len == 0) {
|
||||
(void) fprintf(io->errs,
|
||||
"__ops_validate_key_cb: user attribute length 0");
|
||||
return OPS_FINISHED;
|
||||
"pgp_validate_key_cb: user attribute length 0");
|
||||
return PGP_FINISHED;
|
||||
}
|
||||
(void) fprintf(io->outs, "user attribute, length=%d\n",
|
||||
(int) content->userattr.len);
|
||||
if (key->userattr.len) {
|
||||
__ops_data_free(&key->userattr);
|
||||
pgp_data_free(&key->userattr);
|
||||
}
|
||||
key->userattr = content->userattr;
|
||||
key->last_seen = ATTRIBUTE;
|
||||
return OPS_KEEP_MEMORY;
|
||||
return PGP_KEEP_MEMORY;
|
||||
|
||||
case OPS_PTAG_CT_SIGNATURE: /* V3 sigs */
|
||||
case OPS_PTAG_CT_SIGNATURE_FOOTER: /* V4 sigs */
|
||||
case PGP_PTAG_CT_SIGNATURE: /* V3 sigs */
|
||||
case PGP_PTAG_CT_SIGNATURE_FOOTER: /* V4 sigs */
|
||||
from = 0;
|
||||
signer = __ops_getkeybyid(io, key->keyring,
|
||||
signer = pgp_getkeybyid(io, key->keyring,
|
||||
content->sig.info.signer_id,
|
||||
&from, &sigkey);
|
||||
if (!signer) {
|
||||
@ -306,8 +306,8 @@ __ops_validate_key_cb(const __ops_packet_t *pkt, __ops_cbdata_t *cbinfo)
|
||||
&key->result->unknown_sigs,
|
||||
&key->result->unknownc)) {
|
||||
(void) fprintf(io->errs,
|
||||
"__ops_validate_key_cb: user attribute length 0");
|
||||
return OPS_FINISHED;
|
||||
"pgp_validate_key_cb: user attribute length 0");
|
||||
return PGP_FINISHED;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -316,60 +316,60 @@ __ops_validate_key_cb(const __ops_packet_t *pkt, __ops_cbdata_t *cbinfo)
|
||||
"WARNING: signature made with encryption key\n");
|
||||
}
|
||||
switch (content->sig.info.type) {
|
||||
case OPS_CERT_GENERIC:
|
||||
case OPS_CERT_PERSONA:
|
||||
case OPS_CERT_CASUAL:
|
||||
case OPS_CERT_POSITIVE:
|
||||
case OPS_SIG_REV_CERT:
|
||||
case PGP_CERT_GENERIC:
|
||||
case PGP_CERT_PERSONA:
|
||||
case PGP_CERT_CASUAL:
|
||||
case PGP_CERT_POSITIVE:
|
||||
case PGP_SIG_REV_CERT:
|
||||
valid = (key->last_seen == ID) ?
|
||||
__ops_check_useridcert_sig(&key->pubkey,
|
||||
pgp_check_useridcert_sig(&key->pubkey,
|
||||
key->userid,
|
||||
&content->sig,
|
||||
__ops_get_pubkey(signer),
|
||||
pgp_get_pubkey(signer),
|
||||
key->reader->key->packets[
|
||||
key->reader->packet].raw) :
|
||||
__ops_check_userattrcert_sig(&key->pubkey,
|
||||
pgp_check_userattrcert_sig(&key->pubkey,
|
||||
&key->userattr,
|
||||
&content->sig,
|
||||
__ops_get_pubkey(signer),
|
||||
pgp_get_pubkey(signer),
|
||||
key->reader->key->packets[
|
||||
key->reader->packet].raw);
|
||||
break;
|
||||
|
||||
case OPS_SIG_SUBKEY:
|
||||
case PGP_SIG_SUBKEY:
|
||||
/*
|
||||
* XXX: we should also check that the signer is the
|
||||
* key we are validating, I think.
|
||||
*/
|
||||
valid = __ops_check_subkey_sig(&key->pubkey,
|
||||
valid = pgp_check_subkey_sig(&key->pubkey,
|
||||
&key->subkey,
|
||||
&content->sig,
|
||||
__ops_get_pubkey(signer),
|
||||
pgp_get_pubkey(signer),
|
||||
key->reader->key->packets[
|
||||
key->reader->packet].raw);
|
||||
break;
|
||||
|
||||
case OPS_SIG_DIRECT:
|
||||
valid = __ops_check_direct_sig(&key->pubkey,
|
||||
case PGP_SIG_DIRECT:
|
||||
valid = pgp_check_direct_sig(&key->pubkey,
|
||||
&content->sig,
|
||||
__ops_get_pubkey(signer),
|
||||
pgp_get_pubkey(signer),
|
||||
key->reader->key->packets[
|
||||
key->reader->packet].raw);
|
||||
break;
|
||||
|
||||
case OPS_SIG_STANDALONE:
|
||||
case OPS_SIG_PRIMARY:
|
||||
case OPS_SIG_REV_KEY:
|
||||
case OPS_SIG_REV_SUBKEY:
|
||||
case OPS_SIG_TIMESTAMP:
|
||||
case OPS_SIG_3RD_PARTY:
|
||||
OPS_ERROR_1(errors, OPS_E_UNIMPLEMENTED,
|
||||
case PGP_SIG_STANDALONE:
|
||||
case PGP_SIG_PRIMARY:
|
||||
case PGP_SIG_REV_KEY:
|
||||
case PGP_SIG_REV_SUBKEY:
|
||||
case PGP_SIG_TIMESTAMP:
|
||||
case PGP_SIG_3RD_PARTY:
|
||||
PGP_ERROR_1(errors, PGP_E_UNIMPLEMENTED,
|
||||
"Sig Verification type 0x%02x not done yet\n",
|
||||
content->sig.info.type);
|
||||
break;
|
||||
|
||||
default:
|
||||
OPS_ERROR_1(errors, OPS_E_UNIMPLEMENTED,
|
||||
PGP_ERROR_1(errors, PGP_E_UNIMPLEMENTED,
|
||||
"Unexpected signature type 0x%02x\n",
|
||||
content->sig.info.type);
|
||||
}
|
||||
@ -378,33 +378,33 @@ __ops_validate_key_cb(const __ops_packet_t *pkt, __ops_cbdata_t *cbinfo)
|
||||
if (!add_sig_to_list(&content->sig.info,
|
||||
&key->result->valid_sigs,
|
||||
&key->result->validc)) {
|
||||
OPS_ERROR(errors, OPS_E_UNIMPLEMENTED,
|
||||
PGP_ERROR(errors, PGP_E_UNIMPLEMENTED,
|
||||
"Can't add good sig to list\n");
|
||||
}
|
||||
} else {
|
||||
OPS_ERROR(errors, OPS_E_V_BAD_SIGNATURE, "Bad Sig");
|
||||
PGP_ERROR(errors, PGP_E_V_BAD_SIGNATURE, "Bad Sig");
|
||||
if (!add_sig_to_list(&content->sig.info,
|
||||
&key->result->invalid_sigs,
|
||||
&key->result->invalidc)) {
|
||||
OPS_ERROR(errors, OPS_E_UNIMPLEMENTED,
|
||||
PGP_ERROR(errors, PGP_E_UNIMPLEMENTED,
|
||||
"Can't add good sig to list\n");
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
/* ignore these */
|
||||
case OPS_PARSER_PTAG:
|
||||
case OPS_PTAG_CT_SIGNATURE_HEADER:
|
||||
case OPS_PARSER_PACKET_END:
|
||||
case PGP_PARSER_PTAG:
|
||||
case PGP_PTAG_CT_SIGNATURE_HEADER:
|
||||
case PGP_PARSER_PACKET_END:
|
||||
break;
|
||||
|
||||
case OPS_GET_PASSPHRASE:
|
||||
case PGP_GET_PASSPHRASE:
|
||||
if (key->getpassphrase) {
|
||||
return key->getpassphrase(pkt, cbinfo);
|
||||
}
|
||||
break;
|
||||
|
||||
case OPS_PTAG_CT_TRUST:
|
||||
case PGP_PTAG_CT_TRUST:
|
||||
/* 1 byte for level (depth), 1 byte for trust amount */
|
||||
printf("trust dump\n");
|
||||
printf("Got trust\n");
|
||||
@ -415,78 +415,78 @@ __ops_validate_key_cb(const __ops_packet_t *pkt, __ops_cbdata_t *cbinfo)
|
||||
|
||||
default:
|
||||
(void) fprintf(stderr, "unexpected tag=0x%x\n", pkt->tag);
|
||||
return OPS_FINISHED;
|
||||
return PGP_FINISHED;
|
||||
}
|
||||
return OPS_RELEASE_MEMORY;
|
||||
return PGP_RELEASE_MEMORY;
|
||||
}
|
||||
|
||||
__ops_cb_ret_t
|
||||
validate_data_cb(const __ops_packet_t *pkt, __ops_cbdata_t *cbinfo)
|
||||
pgp_cb_ret_t
|
||||
validate_data_cb(const pgp_packet_t *pkt, pgp_cbdata_t *cbinfo)
|
||||
{
|
||||
const __ops_contents_t *content = &pkt->u;
|
||||
const __ops_key_t *signer;
|
||||
const pgp_contents_t *content = &pkt->u;
|
||||
const pgp_key_t *signer;
|
||||
validate_data_cb_t *data;
|
||||
__ops_pubkey_t *sigkey;
|
||||
__ops_error_t **errors;
|
||||
__ops_io_t *io;
|
||||
pgp_pubkey_t *sigkey;
|
||||
pgp_error_t **errors;
|
||||
pgp_io_t *io;
|
||||
unsigned from;
|
||||
unsigned valid = 0;
|
||||
|
||||
io = cbinfo->io;
|
||||
if (__ops_get_debug_level(__FILE__)) {
|
||||
if (pgp_get_debug_level(__FILE__)) {
|
||||
(void) fprintf(io->errs, "validate_data_cb: %s\n",
|
||||
__ops_show_packet_tag(pkt->tag));
|
||||
pgp_show_packet_tag(pkt->tag));
|
||||
}
|
||||
data = __ops_callback_arg(cbinfo);
|
||||
errors = __ops_callback_errors(cbinfo);
|
||||
data = pgp_callback_arg(cbinfo);
|
||||
errors = pgp_callback_errors(cbinfo);
|
||||
switch (pkt->tag) {
|
||||
case OPS_PTAG_CT_SIGNED_CLEARTEXT_HEADER:
|
||||
case PGP_PTAG_CT_SIGNED_CLEARTEXT_HEADER:
|
||||
/*
|
||||
* ignore - this gives us the "Armor Header" line "Hash:
|
||||
* SHA1" or similar
|
||||
*/
|
||||
break;
|
||||
|
||||
case OPS_PTAG_CT_LITDATA_HEADER:
|
||||
case PGP_PTAG_CT_LITDATA_HEADER:
|
||||
/* ignore */
|
||||
break;
|
||||
|
||||
case OPS_PTAG_CT_LITDATA_BODY:
|
||||
case PGP_PTAG_CT_LITDATA_BODY:
|
||||
data->data.litdata_body = content->litdata_body;
|
||||
data->type = LITDATA;
|
||||
__ops_memory_add(data->mem, data->data.litdata_body.data,
|
||||
pgp_memory_add(data->mem, data->data.litdata_body.data,
|
||||
data->data.litdata_body.length);
|
||||
return OPS_KEEP_MEMORY;
|
||||
return PGP_KEEP_MEMORY;
|
||||
|
||||
case OPS_PTAG_CT_SIGNED_CLEARTEXT_BODY:
|
||||
case PGP_PTAG_CT_SIGNED_CLEARTEXT_BODY:
|
||||
data->data.cleartext_body = content->cleartext_body;
|
||||
data->type = SIGNED_CLEARTEXT;
|
||||
__ops_memory_add(data->mem, data->data.cleartext_body.data,
|
||||
pgp_memory_add(data->mem, data->data.cleartext_body.data,
|
||||
data->data.cleartext_body.length);
|
||||
return OPS_KEEP_MEMORY;
|
||||
return PGP_KEEP_MEMORY;
|
||||
|
||||
case OPS_PTAG_CT_SIGNED_CLEARTEXT_TRAILER:
|
||||
/* this gives us an __ops_hash_t struct */
|
||||
case PGP_PTAG_CT_SIGNED_CLEARTEXT_TRAILER:
|
||||
/* this gives us an pgp_hash_t struct */
|
||||
break;
|
||||
|
||||
case OPS_PTAG_CT_SIGNATURE: /* V3 sigs */
|
||||
case OPS_PTAG_CT_SIGNATURE_FOOTER: /* V4 sigs */
|
||||
if (__ops_get_debug_level(__FILE__)) {
|
||||
case PGP_PTAG_CT_SIGNATURE: /* V3 sigs */
|
||||
case PGP_PTAG_CT_SIGNATURE_FOOTER: /* V4 sigs */
|
||||
if (pgp_get_debug_level(__FILE__)) {
|
||||
hexdump(io->outs, "hashed data", content->sig.info.v4_hashed,
|
||||
content->sig.info.v4_hashlen);
|
||||
hexdump(io->outs, "signer id", content->sig.info.signer_id,
|
||||
sizeof(content->sig.info.signer_id));
|
||||
}
|
||||
from = 0;
|
||||
signer = __ops_getkeybyid(io, data->keyring,
|
||||
signer = pgp_getkeybyid(io, data->keyring,
|
||||
content->sig.info.signer_id, &from, &sigkey);
|
||||
if (!signer) {
|
||||
OPS_ERROR(errors, OPS_E_V_UNKNOWN_SIGNER,
|
||||
PGP_ERROR(errors, PGP_E_V_UNKNOWN_SIGNER,
|
||||
"Unknown Signer");
|
||||
if (!add_sig_to_list(&content->sig.info,
|
||||
&data->result->unknown_sigs,
|
||||
&data->result->unknownc)) {
|
||||
OPS_ERROR(errors, OPS_E_V_UNKNOWN_SIGNER,
|
||||
PGP_ERROR(errors, PGP_E_V_UNKNOWN_SIGNER,
|
||||
"Can't add unknown sig to list");
|
||||
}
|
||||
break;
|
||||
@ -502,30 +502,30 @@ validate_data_cb(const __ops_packet_t *pkt, __ops_cbdata_t *cbinfo)
|
||||
data->result->duration = content->sig.info.duration;
|
||||
}
|
||||
switch (content->sig.info.type) {
|
||||
case OPS_SIG_BINARY:
|
||||
case OPS_SIG_TEXT:
|
||||
if (__ops_mem_len(data->mem) == 0 &&
|
||||
case PGP_SIG_BINARY:
|
||||
case PGP_SIG_TEXT:
|
||||
if (pgp_mem_len(data->mem) == 0 &&
|
||||
data->detachname) {
|
||||
/* check we have seen some data */
|
||||
/* if not, need to read from detached name */
|
||||
(void) fprintf(io->errs,
|
||||
"netpgp: assuming signed data in \"%s\"\n",
|
||||
data->detachname);
|
||||
data->mem = __ops_memory_new();
|
||||
__ops_mem_readfile(data->mem, data->detachname);
|
||||
data->mem = pgp_memory_new();
|
||||
pgp_mem_readfile(data->mem, data->detachname);
|
||||
}
|
||||
if (__ops_get_debug_level(__FILE__)) {
|
||||
if (pgp_get_debug_level(__FILE__)) {
|
||||
hexdump(stderr, "sig dump", (const uint8_t *)(const void *)&content->sig,
|
||||
sizeof(content->sig));
|
||||
}
|
||||
valid = check_binary_sig(__ops_mem_data(data->mem),
|
||||
(const unsigned)__ops_mem_len(data->mem),
|
||||
valid = check_binary_sig(pgp_mem_data(data->mem),
|
||||
(const unsigned)pgp_mem_len(data->mem),
|
||||
&content->sig,
|
||||
__ops_get_pubkey(signer));
|
||||
pgp_get_pubkey(signer));
|
||||
break;
|
||||
|
||||
default:
|
||||
OPS_ERROR_1(errors, OPS_E_UNIMPLEMENTED,
|
||||
PGP_ERROR_1(errors, PGP_E_UNIMPLEMENTED,
|
||||
"No Sig Verification type 0x%02x yet\n",
|
||||
content->sig.info.type);
|
||||
break;
|
||||
@ -536,57 +536,57 @@ validate_data_cb(const __ops_packet_t *pkt, __ops_cbdata_t *cbinfo)
|
||||
if (!add_sig_to_list(&content->sig.info,
|
||||
&data->result->valid_sigs,
|
||||
&data->result->validc)) {
|
||||
OPS_ERROR(errors, OPS_E_V_BAD_SIGNATURE,
|
||||
PGP_ERROR(errors, PGP_E_V_BAD_SIGNATURE,
|
||||
"Can't add good sig to list");
|
||||
}
|
||||
} else {
|
||||
OPS_ERROR(errors, OPS_E_V_BAD_SIGNATURE,
|
||||
PGP_ERROR(errors, PGP_E_V_BAD_SIGNATURE,
|
||||
"Bad Signature");
|
||||
if (!add_sig_to_list(&content->sig.info,
|
||||
&data->result->invalid_sigs,
|
||||
&data->result->invalidc)) {
|
||||
OPS_ERROR(errors, OPS_E_V_BAD_SIGNATURE,
|
||||
PGP_ERROR(errors, PGP_E_V_BAD_SIGNATURE,
|
||||
"Can't add good sig to list");
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
/* ignore these */
|
||||
case OPS_PARSER_PTAG:
|
||||
case OPS_PTAG_CT_SIGNATURE_HEADER:
|
||||
case OPS_PTAG_CT_ARMOUR_HEADER:
|
||||
case OPS_PTAG_CT_ARMOUR_TRAILER:
|
||||
case OPS_PTAG_CT_1_PASS_SIG:
|
||||
case PGP_PARSER_PTAG:
|
||||
case PGP_PTAG_CT_SIGNATURE_HEADER:
|
||||
case PGP_PTAG_CT_ARMOUR_HEADER:
|
||||
case PGP_PTAG_CT_ARMOUR_TRAILER:
|
||||
case PGP_PTAG_CT_1_PASS_SIG:
|
||||
break;
|
||||
|
||||
case OPS_PARSER_PACKET_END:
|
||||
case PGP_PARSER_PACKET_END:
|
||||
break;
|
||||
|
||||
default:
|
||||
OPS_ERROR(errors, OPS_E_V_NO_SIGNATURE, "No signature");
|
||||
PGP_ERROR(errors, PGP_E_V_NO_SIGNATURE, "No signature");
|
||||
break;
|
||||
}
|
||||
return OPS_RELEASE_MEMORY;
|
||||
return PGP_RELEASE_MEMORY;
|
||||
}
|
||||
|
||||
static void
|
||||
keydata_destroyer(__ops_reader_t *readinfo)
|
||||
keydata_destroyer(pgp_reader_t *readinfo)
|
||||
{
|
||||
free(__ops_reader_get_arg(readinfo));
|
||||
free(pgp_reader_get_arg(readinfo));
|
||||
}
|
||||
|
||||
void
|
||||
__ops_keydata_reader_set(__ops_stream_t *stream, const __ops_key_t *key)
|
||||
pgp_keydata_reader_set(pgp_stream_t *stream, const pgp_key_t *key)
|
||||
{
|
||||
validate_reader_t *data;
|
||||
|
||||
if ((data = calloc(1, sizeof(*data))) == NULL) {
|
||||
(void) fprintf(stderr, "__ops_keydata_reader_set: bad alloc\n");
|
||||
(void) fprintf(stderr, "pgp_keydata_reader_set: bad alloc\n");
|
||||
} else {
|
||||
data->key = key;
|
||||
data->packet = 0;
|
||||
data->offset = 0;
|
||||
__ops_reader_set(stream, keydata_reader, keydata_destroyer, data);
|
||||
pgp_reader_set(stream, keydata_reader, keydata_destroyer, data);
|
||||
}
|
||||
}
|
||||
|
||||
@ -630,7 +630,7 @@ fmtsecs(int64_t n, char *buf, size_t size)
|
||||
or no valid signatures; else 1
|
||||
*/
|
||||
static unsigned
|
||||
validate_result_status(FILE *errs, const char *f, __ops_validation_t *val)
|
||||
validate_result_status(FILE *errs, const char *f, pgp_validation_t *val)
|
||||
{
|
||||
time_t now;
|
||||
time_t t;
|
||||
@ -676,16 +676,16 @@ validate_result_status(FILE *errs, const char *f, __ops_validation_t *val)
|
||||
* \param cb_get_passphrase Callback to use to get passphrase
|
||||
* \return 1 if all signatures OK; else 0
|
||||
* \note It is the caller's responsiblity to free result after use.
|
||||
* \sa __ops_validate_result_free()
|
||||
* \sa pgp_validate_result_free()
|
||||
*/
|
||||
unsigned
|
||||
__ops_validate_key_sigs(__ops_validation_t *result,
|
||||
const __ops_key_t *key,
|
||||
const __ops_keyring_t *keyring,
|
||||
__ops_cb_ret_t cb_get_passphrase(const __ops_packet_t *,
|
||||
__ops_cbdata_t *))
|
||||
pgp_validate_key_sigs(pgp_validation_t *result,
|
||||
const pgp_key_t *key,
|
||||
const pgp_keyring_t *keyring,
|
||||
pgp_cb_ret_t cb_get_passphrase(const pgp_packet_t *,
|
||||
pgp_cbdata_t *))
|
||||
{
|
||||
__ops_stream_t *stream;
|
||||
pgp_stream_t *stream;
|
||||
validate_key_cb_t keysigs;
|
||||
const int printerrors = 1;
|
||||
|
||||
@ -693,29 +693,29 @@ __ops_validate_key_sigs(__ops_validation_t *result,
|
||||
keysigs.result = result;
|
||||
keysigs.getpassphrase = cb_get_passphrase;
|
||||
|
||||
stream = __ops_new(sizeof(*stream));
|
||||
/* __ops_parse_options(&opt,OPS_PTAG_CT_SIGNATURE,OPS_PARSE_PARSED); */
|
||||
stream = pgp_new(sizeof(*stream));
|
||||
/* pgp_parse_options(&opt,PGP_PTAG_CT_SIGNATURE,PGP_PARSE_PARSED); */
|
||||
|
||||
keysigs.keyring = keyring;
|
||||
|
||||
__ops_set_callback(stream, __ops_validate_key_cb, &keysigs);
|
||||
pgp_set_callback(stream, pgp_validate_key_cb, &keysigs);
|
||||
stream->readinfo.accumulate = 1;
|
||||
__ops_keydata_reader_set(stream, key);
|
||||
pgp_keydata_reader_set(stream, key);
|
||||
|
||||
/* Note: Coverity incorrectly reports an error that keysigs.reader */
|
||||
/* is never used. */
|
||||
keysigs.reader = stream->readinfo.arg;
|
||||
|
||||
__ops_parse(stream, !printerrors);
|
||||
pgp_parse(stream, !printerrors);
|
||||
|
||||
__ops_pubkey_free(&keysigs.pubkey);
|
||||
pgp_pubkey_free(&keysigs.pubkey);
|
||||
if (keysigs.subkey.version) {
|
||||
__ops_pubkey_free(&keysigs.subkey);
|
||||
pgp_pubkey_free(&keysigs.subkey);
|
||||
}
|
||||
__ops_userid_free(&keysigs.userid);
|
||||
__ops_data_free(&keysigs.userattr);
|
||||
pgp_userid_free(&keysigs.userid);
|
||||
pgp_data_free(&keysigs.userattr);
|
||||
|
||||
__ops_stream_delete(stream);
|
||||
pgp_stream_delete(stream);
|
||||
|
||||
return (!result->invalidc && !result->unknownc && result->validc);
|
||||
}
|
||||
@ -726,19 +726,19 @@ __ops_validate_key_sigs(__ops_validation_t *result,
|
||||
\param ring Keyring to use
|
||||
\param cb_get_passphrase Callback to use to get passphrase
|
||||
\note It is the caller's responsibility to free result after use.
|
||||
\sa __ops_validate_result_free()
|
||||
\sa pgp_validate_result_free()
|
||||
*/
|
||||
unsigned
|
||||
__ops_validate_all_sigs(__ops_validation_t *result,
|
||||
const __ops_keyring_t *ring,
|
||||
__ops_cb_ret_t cb_get_passphrase(const __ops_packet_t *,
|
||||
__ops_cbdata_t *))
|
||||
pgp_validate_all_sigs(pgp_validation_t *result,
|
||||
const pgp_keyring_t *ring,
|
||||
pgp_cb_ret_t cb_get_passphrase(const pgp_packet_t *,
|
||||
pgp_cbdata_t *))
|
||||
{
|
||||
unsigned n;
|
||||
|
||||
(void) memset(result, 0x0, sizeof(*result));
|
||||
for (n = 0; n < ring->keyc; ++n) {
|
||||
__ops_validate_key_sigs(result, &ring->keys[n], ring,
|
||||
pgp_validate_key_sigs(result, &ring->keys[n], ring,
|
||||
cb_get_passphrase);
|
||||
}
|
||||
return validate_result_status(stderr, "keyring", result);
|
||||
@ -751,7 +751,7 @@ __ops_validate_all_sigs(__ops_validation_t *result,
|
||||
\note Must be called after validation functions
|
||||
*/
|
||||
void
|
||||
__ops_validate_result_free(__ops_validation_t *result)
|
||||
pgp_validate_result_free(pgp_validation_t *result)
|
||||
{
|
||||
if (result != NULL) {
|
||||
if (result->valid_sigs) {
|
||||
@ -780,18 +780,18 @@ __ops_validate_result_free(__ops_validation_t *result)
|
||||
\note After verification, result holds the details of all keys which
|
||||
have passed, failed and not been recognised.
|
||||
\note It is the caller's responsiblity to call
|
||||
__ops_validate_result_free(result) after use.
|
||||
pgp_validate_result_free(result) after use.
|
||||
*/
|
||||
unsigned
|
||||
__ops_validate_file(__ops_io_t *io,
|
||||
__ops_validation_t *result,
|
||||
pgp_validate_file(pgp_io_t *io,
|
||||
pgp_validation_t *result,
|
||||
const char *infile,
|
||||
const char *outfile,
|
||||
const int user_says_armoured,
|
||||
const __ops_keyring_t *keyring)
|
||||
const pgp_keyring_t *keyring)
|
||||
{
|
||||
validate_data_cb_t validation;
|
||||
__ops_stream_t *parse = NULL;
|
||||
pgp_stream_t *parse = NULL;
|
||||
struct stat st;
|
||||
const char *signame;
|
||||
const int printerrors = 1;
|
||||
@ -805,7 +805,7 @@ __ops_validate_file(__ops_io_t *io,
|
||||
|
||||
if (stat(infile, &st) < 0) {
|
||||
(void) fprintf(io->errs,
|
||||
"__ops_validate_file: can't open '%s'\n", infile);
|
||||
"pgp_validate_file: can't open '%s'\n", infile);
|
||||
return 0;
|
||||
}
|
||||
realarmour = user_says_armoured;
|
||||
@ -829,7 +829,7 @@ __ops_validate_file(__ops_io_t *io,
|
||||
signame = infile;
|
||||
}
|
||||
(void) memset(&validation, 0x0, sizeof(validation));
|
||||
infd = __ops_setup_file_read(io, &parse, signame, &validation,
|
||||
infd = pgp_setup_file_read(io, &parse, signame, &validation,
|
||||
validate_data_cb, 1);
|
||||
if (infd < 0) {
|
||||
return 0;
|
||||
@ -842,24 +842,24 @@ __ops_validate_file(__ops_io_t *io,
|
||||
/* Set verification reader and handling options */
|
||||
validation.result = result;
|
||||
validation.keyring = keyring;
|
||||
validation.mem = __ops_memory_new();
|
||||
__ops_memory_init(validation.mem, 128);
|
||||
validation.mem = pgp_memory_new();
|
||||
pgp_memory_init(validation.mem, 128);
|
||||
/* Note: Coverity incorrectly reports an error that validation.reader */
|
||||
/* is never used. */
|
||||
validation.reader = parse->readinfo.arg;
|
||||
|
||||
if (realarmour) {
|
||||
__ops_reader_push_dearmour(parse);
|
||||
pgp_reader_push_dearmour(parse);
|
||||
}
|
||||
|
||||
/* Do the verification */
|
||||
__ops_parse(parse, !printerrors);
|
||||
pgp_parse(parse, !printerrors);
|
||||
|
||||
/* Tidy up */
|
||||
if (realarmour) {
|
||||
__ops_reader_pop_dearmour(parse);
|
||||
pgp_reader_pop_dearmour(parse);
|
||||
}
|
||||
__ops_teardown_file_read(parse, infd);
|
||||
pgp_teardown_file_read(parse, infd);
|
||||
|
||||
ret = validate_result_status(io->errs, infile, result);
|
||||
|
||||
@ -881,8 +881,8 @@ __ops_validate_file(__ops_io_t *io,
|
||||
char *cp;
|
||||
int i;
|
||||
|
||||
len = (unsigned)__ops_mem_len(validation.mem);
|
||||
cp = __ops_mem_data(validation.mem);
|
||||
len = (unsigned)pgp_mem_len(validation.mem);
|
||||
cp = pgp_mem_data(validation.mem);
|
||||
for (i = 0 ; i < (int)len ; i += cc) {
|
||||
cc = (int)write(outfd, &cp[i], (unsigned)(len - i));
|
||||
if (cc < 0) {
|
||||
@ -897,13 +897,13 @@ __ops_validate_file(__ops_io_t *io,
|
||||
}
|
||||
}
|
||||
}
|
||||
__ops_memory_free(validation.mem);
|
||||
pgp_memory_free(validation.mem);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
\ingroup HighLevel_Verify
|
||||
\brief Verifies the signatures in a __ops_memory_t struct
|
||||
\brief Verifies the signatures in a pgp_memory_t struct
|
||||
\param result Where to put the result
|
||||
\param mem Memory to be validated
|
||||
\param user_says_armoured Treat data as armoured, if set
|
||||
@ -912,57 +912,57 @@ __ops_validate_file(__ops_io_t *io,
|
||||
\note After verification, result holds the details of all keys which
|
||||
have passed, failed and not been recognised.
|
||||
\note It is the caller's responsiblity to call
|
||||
__ops_validate_result_free(result) after use.
|
||||
pgp_validate_result_free(result) after use.
|
||||
*/
|
||||
|
||||
unsigned
|
||||
__ops_validate_mem(__ops_io_t *io,
|
||||
__ops_validation_t *result,
|
||||
__ops_memory_t *mem,
|
||||
__ops_memory_t **cat,
|
||||
pgp_validate_mem(pgp_io_t *io,
|
||||
pgp_validation_t *result,
|
||||
pgp_memory_t *mem,
|
||||
pgp_memory_t **cat,
|
||||
const int user_says_armoured,
|
||||
const __ops_keyring_t *keyring)
|
||||
const pgp_keyring_t *keyring)
|
||||
{
|
||||
validate_data_cb_t validation;
|
||||
__ops_stream_t *stream = NULL;
|
||||
pgp_stream_t *stream = NULL;
|
||||
const int printerrors = 1;
|
||||
int realarmour;
|
||||
|
||||
__ops_setup_memory_read(io, &stream, mem, &validation, validate_data_cb, 1);
|
||||
pgp_setup_memory_read(io, &stream, mem, &validation, validate_data_cb, 1);
|
||||
/* Set verification reader and handling options */
|
||||
(void) memset(&validation, 0x0, sizeof(validation));
|
||||
validation.result = result;
|
||||
validation.keyring = keyring;
|
||||
validation.mem = __ops_memory_new();
|
||||
__ops_memory_init(validation.mem, 128);
|
||||
validation.mem = pgp_memory_new();
|
||||
pgp_memory_init(validation.mem, 128);
|
||||
/* Note: Coverity incorrectly reports an error that validation.reader */
|
||||
/* is never used. */
|
||||
validation.reader = stream->readinfo.arg;
|
||||
|
||||
if ((realarmour = user_says_armoured) != 0 ||
|
||||
strncmp(__ops_mem_data(mem),
|
||||
strncmp(pgp_mem_data(mem),
|
||||
"-----BEGIN PGP MESSAGE-----", 27) == 0) {
|
||||
realarmour = 1;
|
||||
}
|
||||
if (realarmour) {
|
||||
__ops_reader_push_dearmour(stream);
|
||||
pgp_reader_push_dearmour(stream);
|
||||
}
|
||||
|
||||
/* Do the verification */
|
||||
__ops_parse(stream, !printerrors);
|
||||
pgp_parse(stream, !printerrors);
|
||||
|
||||
/* Tidy up */
|
||||
if (realarmour) {
|
||||
__ops_reader_pop_dearmour(stream);
|
||||
pgp_reader_pop_dearmour(stream);
|
||||
}
|
||||
__ops_teardown_memory_read(stream, mem);
|
||||
pgp_teardown_memory_read(stream, mem);
|
||||
|
||||
/* this is triggered only for --cat output */
|
||||
if (cat) {
|
||||
/* need to send validated output somewhere */
|
||||
*cat = validation.mem;
|
||||
} else {
|
||||
__ops_memory_free(validation.mem);
|
||||
pgp_memory_free(validation.mem);
|
||||
}
|
||||
|
||||
return validate_result_status(io->errs, NULL, result);
|
||||
|
@ -50,28 +50,28 @@
|
||||
#define VALIDATE_H_ 1
|
||||
|
||||
typedef struct {
|
||||
const __ops_key_t *key;
|
||||
const pgp_key_t *key;
|
||||
unsigned packet;
|
||||
unsigned offset;
|
||||
} validate_reader_t;
|
||||
|
||||
/** Struct used with the validate_key_cb callback */
|
||||
typedef struct {
|
||||
__ops_pubkey_t pubkey;
|
||||
__ops_pubkey_t subkey;
|
||||
__ops_seckey_t seckey;
|
||||
pgp_pubkey_t pubkey;
|
||||
pgp_pubkey_t subkey;
|
||||
pgp_seckey_t seckey;
|
||||
enum {
|
||||
ATTRIBUTE = 1,
|
||||
ID
|
||||
} last_seen;
|
||||
uint8_t *userid;
|
||||
__ops_data_t userattr;
|
||||
uint8_t hash[OPS_MAX_HASH_SIZE];
|
||||
const __ops_keyring_t *keyring;
|
||||
pgp_data_t userattr;
|
||||
uint8_t hash[PGP_MAX_HASH_SIZE];
|
||||
const pgp_keyring_t *keyring;
|
||||
validate_reader_t *reader;
|
||||
__ops_validation_t *result;
|
||||
__ops_cb_ret_t(*getpassphrase) (const __ops_packet_t *,
|
||||
__ops_cbdata_t *);
|
||||
pgp_validation_t *result;
|
||||
pgp_cb_ret_t(*getpassphrase) (const pgp_packet_t *,
|
||||
pgp_cbdata_t *);
|
||||
} validate_key_cb_t;
|
||||
|
||||
/** Struct use with the validate_data_cb callback */
|
||||
@ -81,40 +81,40 @@ typedef struct {
|
||||
SIGNED_CLEARTEXT
|
||||
} type;
|
||||
union {
|
||||
__ops_litdata_body_t litdata_body;
|
||||
__ops_fixed_body_t cleartext_body;
|
||||
pgp_litdata_body_t litdata_body;
|
||||
pgp_fixed_body_t cleartext_body;
|
||||
} data;
|
||||
uint8_t hash[OPS_MAX_HASH_SIZE];
|
||||
__ops_memory_t *mem;
|
||||
const __ops_keyring_t *keyring;
|
||||
uint8_t hash[PGP_MAX_HASH_SIZE];
|
||||
pgp_memory_t *mem;
|
||||
const pgp_keyring_t *keyring;
|
||||
validate_reader_t *reader;/* reader-specific arg */
|
||||
__ops_validation_t *result;
|
||||
pgp_validation_t *result;
|
||||
char *detachname;
|
||||
} validate_data_cb_t;
|
||||
|
||||
void __ops_keydata_reader_set(__ops_stream_t *, const __ops_key_t *);
|
||||
void pgp_keydata_reader_set(pgp_stream_t *, const pgp_key_t *);
|
||||
|
||||
__ops_cb_ret_t __ops_validate_key_cb(const __ops_packet_t *, __ops_cbdata_t *);
|
||||
pgp_cb_ret_t pgp_validate_key_cb(const pgp_packet_t *, pgp_cbdata_t *);
|
||||
|
||||
unsigned check_binary_sig(const uint8_t *,
|
||||
const unsigned,
|
||||
const __ops_sig_t *,
|
||||
const __ops_pubkey_t *);
|
||||
const pgp_sig_t *,
|
||||
const pgp_pubkey_t *);
|
||||
|
||||
unsigned __ops_validate_file(__ops_io_t *,
|
||||
__ops_validation_t *,
|
||||
unsigned pgp_validate_file(pgp_io_t *,
|
||||
pgp_validation_t *,
|
||||
const char *,
|
||||
const char *,
|
||||
const int,
|
||||
const __ops_keyring_t *);
|
||||
const pgp_keyring_t *);
|
||||
|
||||
unsigned __ops_validate_mem(__ops_io_t *,
|
||||
__ops_validation_t *,
|
||||
__ops_memory_t *,
|
||||
__ops_memory_t **,
|
||||
unsigned pgp_validate_mem(pgp_io_t *,
|
||||
pgp_validation_t *,
|
||||
pgp_memory_t *,
|
||||
pgp_memory_t **,
|
||||
const int,
|
||||
const __ops_keyring_t *);
|
||||
const pgp_keyring_t *);
|
||||
|
||||
__ops_cb_ret_t validate_data_cb(const __ops_packet_t *, __ops_cbdata_t *);
|
||||
pgp_cb_ret_t validate_data_cb(const pgp_packet_t *, pgp_cbdata_t *);
|
||||
|
||||
#endif /* !VALIDATE_H_ */
|
||||
|
@ -58,7 +58,7 @@
|
||||
#endif
|
||||
|
||||
/* development versions have .99 suffix */
|
||||
#define NETPGP_BASE_VERSION "3.99.13"
|
||||
#define NETPGP_BASE_VERSION "3.99.14"
|
||||
|
||||
#define NETPGP_VERSION_CAT(a, b) "NetPGP portable " a "/[" b "]"
|
||||
#define NETPGP_VERSION_STRING \
|
||||
|
680
crypto/external/bsd/netpgp/dist/src/lib/writer.c
vendored
680
crypto/external/bsd/netpgp/dist/src/lib/writer.c
vendored
File diff suppressed because it is too large
Load Diff
70
crypto/external/bsd/netpgp/dist/src/lib/writer.h
vendored
70
crypto/external/bsd/netpgp/dist/src/lib/writer.h
vendored
@ -64,56 +64,56 @@
|
||||
* the writer function prototype
|
||||
*/
|
||||
|
||||
typedef struct __ops_writer_t __ops_writer_t;
|
||||
typedef unsigned __ops_writer_func_t(const uint8_t *,
|
||||
typedef struct pgp_writer_t pgp_writer_t;
|
||||
typedef unsigned pgp_writer_func_t(const uint8_t *,
|
||||
unsigned,
|
||||
__ops_error_t **,
|
||||
__ops_writer_t *);
|
||||
pgp_error_t **,
|
||||
pgp_writer_t *);
|
||||
typedef unsigned
|
||||
__ops_writer_finaliser_t(__ops_error_t **, __ops_writer_t *);
|
||||
typedef void __ops_writer_destroyer_t(__ops_writer_t *);
|
||||
pgp_writer_finaliser_t(pgp_error_t **, pgp_writer_t *);
|
||||
typedef void pgp_writer_destroyer_t(pgp_writer_t *);
|
||||
|
||||
/** Writer settings */
|
||||
struct __ops_writer_t {
|
||||
__ops_writer_func_t *writer; /* the writer itself */
|
||||
__ops_writer_finaliser_t *finaliser; /* the writer's finaliser */
|
||||
__ops_writer_destroyer_t *destroyer; /* the writer's destroyer */
|
||||
struct pgp_writer_t {
|
||||
pgp_writer_func_t *writer; /* the writer itself */
|
||||
pgp_writer_finaliser_t *finaliser; /* the writer's finaliser */
|
||||
pgp_writer_destroyer_t *destroyer; /* the writer's destroyer */
|
||||
void *arg; /* writer-specific argument */
|
||||
__ops_writer_t *next; /* next writer in the stack */
|
||||
__ops_io_t *io; /* IO for errors and output */
|
||||
pgp_writer_t *next; /* next writer in the stack */
|
||||
pgp_io_t *io; /* IO for errors and output */
|
||||
};
|
||||
|
||||
|
||||
void *__ops_writer_get_arg(__ops_writer_t *);
|
||||
void *pgp_writer_get_arg(pgp_writer_t *);
|
||||
|
||||
void __ops_writer_set(__ops_output_t *,
|
||||
__ops_writer_func_t *,
|
||||
__ops_writer_finaliser_t *,
|
||||
__ops_writer_destroyer_t *,
|
||||
void pgp_writer_set(pgp_output_t *,
|
||||
pgp_writer_func_t *,
|
||||
pgp_writer_finaliser_t *,
|
||||
pgp_writer_destroyer_t *,
|
||||
void *);
|
||||
void __ops_writer_push(__ops_output_t *,
|
||||
__ops_writer_func_t *,
|
||||
__ops_writer_finaliser_t *,
|
||||
__ops_writer_destroyer_t *,
|
||||
void pgp_writer_push(pgp_output_t *,
|
||||
pgp_writer_func_t *,
|
||||
pgp_writer_finaliser_t *,
|
||||
pgp_writer_destroyer_t *,
|
||||
void *);
|
||||
void __ops_writer_pop(__ops_output_t *);
|
||||
unsigned __ops_writer_passthrough(const uint8_t *,
|
||||
void pgp_writer_pop(pgp_output_t *);
|
||||
unsigned pgp_writer_passthrough(const uint8_t *,
|
||||
unsigned,
|
||||
__ops_error_t **,
|
||||
__ops_writer_t *);
|
||||
pgp_error_t **,
|
||||
pgp_writer_t *);
|
||||
|
||||
void __ops_writer_set_fd(__ops_output_t *, int);
|
||||
unsigned __ops_writer_close(__ops_output_t *);
|
||||
void pgp_writer_set_fd(pgp_output_t *, int);
|
||||
unsigned pgp_writer_close(pgp_output_t *);
|
||||
|
||||
unsigned __ops_write(__ops_output_t *, const void *, unsigned);
|
||||
unsigned __ops_write_length(__ops_output_t *, unsigned);
|
||||
unsigned __ops_write_ptag(__ops_output_t *, __ops_content_enum);
|
||||
unsigned __ops_write_scalar(__ops_output_t *, unsigned, unsigned);
|
||||
unsigned __ops_write_mpi(__ops_output_t *, const BIGNUM *);
|
||||
unsigned pgp_write(pgp_output_t *, const void *, unsigned);
|
||||
unsigned pgp_write_length(pgp_output_t *, unsigned);
|
||||
unsigned pgp_write_ptag(pgp_output_t *, pgp_content_enum);
|
||||
unsigned pgp_write_scalar(pgp_output_t *, unsigned, unsigned);
|
||||
unsigned pgp_write_mpi(pgp_output_t *, const BIGNUM *);
|
||||
|
||||
void __ops_writer_info_delete(__ops_writer_t *);
|
||||
unsigned __ops_writer_info_finalise(__ops_error_t **, __ops_writer_t *);
|
||||
void pgp_writer_info_delete(pgp_writer_t *);
|
||||
unsigned pgp_writer_info_finalise(pgp_error_t **, pgp_writer_t *);
|
||||
|
||||
void __ops_push_stream_enc_se_ip(__ops_output_t *, const __ops_key_t *, const char *);
|
||||
void pgp_push_stream_enc_se_ip(pgp_output_t *, const pgp_key_t *, const char *);
|
||||
|
||||
#endif /* WRITER_H_ */
|
||||
|
Loading…
Reference in New Issue
Block a user