Make this compile (WARNS=1) on NetBSD.
Add reachover library Makefile for the external framework.
This commit is contained in:
parent
9b993b5409
commit
5e633613d2
crypto/external
bsd/openpgpsdk
dist
include/openpgpsdk
src/lib
lib
lib
7
crypto/external/bsd/openpgpsdk/dist/include/openpgpsdk/configure.h
vendored
Normal file
7
crypto/external/bsd/openpgpsdk/dist/include/openpgpsdk/configure.h
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
/* generated by configure from include/openpgpsdk/configure.h.template. Don't edit. */
|
||||
|
||||
#undef HAVE_ALLOCA_H
|
||||
#define TIME_T_FMT "%lld"
|
||||
|
||||
/* for silencing unused parameter warnings */
|
||||
#define OPS_USED(x) (x)=(x)
|
@ -77,6 +77,16 @@ ops_boolean_t ops_write_pk_session_key(ops_create_info_t *info,
|
||||
ops_boolean_t ops_write_transferable_public_key(const ops_keydata_t *key, ops_boolean_t armoured, ops_create_info_t *info);
|
||||
ops_boolean_t ops_write_transferable_secret_key(const ops_keydata_t *key, const unsigned char* passphrase, const size_t pplen, ops_boolean_t armoured, ops_create_info_t *info);
|
||||
|
||||
void ops_fast_create_user_id(ops_user_id_t *,unsigned char *);
|
||||
ops_boolean_t ops_write_user_id(const unsigned char *,ops_create_info_t *);
|
||||
void ops_fast_create_rsa_public_key(ops_public_key_t *,time_t, BIGNUM *,BIGNUM *);
|
||||
ops_boolean_t ops_write_rsa_public_key(time_t ,const BIGNUM *, const BIGNUM *, ops_create_info_t *);
|
||||
void ops_fast_create_rsa_secret_key(ops_secret_key_t *,time_t, BIGNUM *,BIGNUM *,BIGNUM *,BIGNUM *, BIGNUM *,BIGNUM *);
|
||||
ops_boolean_t encode_m_buf(const unsigned char *, size_t, const ops_public_key_t *, unsigned char*);
|
||||
ops_boolean_t ops_write_literal_data_from_file(const char *, const ops_literal_data_type_t, ops_create_info_t *);
|
||||
ops_boolean_t ops_write_symmetrically_encrypted_data(const unsigned char *, const int, ops_create_info_t *);
|
||||
|
||||
|
||||
#endif /*OPS_CREATE_H*/
|
||||
|
||||
// eof
|
||||
|
@ -85,4 +85,7 @@ ops_boolean_t ops_add_selfsigned_userid_to_keydata(ops_keydata_t* keydata, ops_u
|
||||
ops_keydata_t *ops_keydata_new(void);
|
||||
void ops_keydata_init(ops_keydata_t* keydata, const ops_content_tag_t type);
|
||||
|
||||
void ops_copy_userid(ops_user_id_t*, const ops_user_id_t*);
|
||||
void ops_copy_packet(ops_packet_t*, const ops_packet_t*);
|
||||
|
||||
#endif
|
||||
|
@ -90,4 +90,7 @@ callback_cmd_get_secret_key(const ops_parser_content_t *content_,ops_parse_cb_in
|
||||
ops_parse_cb_return_t
|
||||
callback_cmd_get_passphrase_from_cmdline(const ops_parser_content_t *content_,ops_parse_cb_info_t *cbinfo);
|
||||
|
||||
/* from reader_fd.c */
|
||||
void ops_reader_set_fd(ops_parse_info_t *,int);
|
||||
|
||||
#endif /*OPS_READERWRITER_H__*/
|
||||
|
@ -24,7 +24,7 @@
|
||||
|
||||
#include <openpgpsdk/readerwriter.h>
|
||||
|
||||
void ops_writer_push_stream_encrypt_se_ip(ops_create_info_t *cinfo,
|
||||
const ops_key_data_t *pub_key);
|
||||
void ops_writer_push_stream_encrypt_se_ip(ops_create_info_t *,
|
||||
const ops_keydata_t *);
|
||||
|
||||
#endif /*__OPS_STREAMWRITER_H__*/
|
||||
|
@ -51,4 +51,6 @@ void hexdump(const unsigned char *src,size_t length);
|
||||
|
||||
void *ops_mallocz(size_t n);
|
||||
|
||||
char *ops_str_from_map(int, ops_map_t *);
|
||||
|
||||
#endif
|
||||
|
@ -38,7 +38,7 @@ ops_boolean_t ops_validate_key_signatures(ops_validate_result_t *result,
|
||||
ops_parse_cb_return_t cb (const ops_parser_content_t *, ops_parse_cb_info_t *));
|
||||
ops_boolean_t ops_validate_all_signatures(ops_validate_result_t *result,
|
||||
const ops_keyring_t *ring,
|
||||
ops_parse_cb_return_t (const ops_parser_content_t *, ops_parse_cb_info_t *));
|
||||
ops_parse_cb_return_t cb (const ops_parser_content_t *, ops_parse_cb_info_t *));
|
||||
|
||||
void ops_keydata_reader_set(ops_parse_info_t *pinfo,
|
||||
const ops_keydata_t *key);
|
||||
@ -99,4 +99,8 @@ ops_validate_key_cb(const ops_parser_content_t *content_,ops_parse_cb_info_t *cb
|
||||
ops_boolean_t ops_validate_file(ops_validate_result_t* result, const char* filename, const int armoured, const ops_keyring_t* keyring);
|
||||
ops_boolean_t ops_validate_mem(ops_validate_result_t *result, ops_memory_t* mem, const int armoured, const ops_keyring_t* keyring);
|
||||
|
||||
ops_parse_cb_return_t
|
||||
validate_data_cb(const ops_parser_content_t *,ops_parse_cb_info_t *);
|
||||
ops_boolean_t validate_result_status(ops_validate_result_t *);
|
||||
|
||||
// EOF
|
||||
|
@ -72,11 +72,12 @@ static int zlib_compressed_data_reader(void *dest,size_t length,
|
||||
ops_parse_cb_info_t *cbinfo)
|
||||
{
|
||||
z_decompress_arg_t *arg=ops_reader_get_arg(rinfo);
|
||||
assert(arg->type==OPS_C_ZIP || arg->type==OPS_C_ZLIB);
|
||||
|
||||
//ops_parser_content_t content;
|
||||
int saved=length;
|
||||
|
||||
assert(arg->type==OPS_C_ZIP || arg->type==OPS_C_ZLIB);
|
||||
|
||||
if(/*arg->region->indeterminate && */ arg->inflate_ret == Z_STREAM_END
|
||||
&& arg->zstream.next_out == &arg->out[arg->offset])
|
||||
return 0;
|
||||
@ -158,11 +159,12 @@ static int bzip2_compressed_data_reader(void *dest,size_t length,
|
||||
ops_parse_cb_info_t *cbinfo)
|
||||
{
|
||||
bz_decompress_arg_t *arg=ops_reader_get_arg(rinfo);
|
||||
assert(arg->type==OPS_C_BZIP2);
|
||||
|
||||
//ops_parser_content_t content;
|
||||
int saved=length;
|
||||
|
||||
assert(arg->type==OPS_C_BZIP2);
|
||||
|
||||
if(arg->inflate_ret == BZ_STREAM_END
|
||||
&& arg->bzstream.next_out == &arg->out[arg->offset])
|
||||
return 0;
|
||||
|
@ -137,6 +137,7 @@ static unsigned secret_key_length(const ops_secret_key_t *key)
|
||||
{
|
||||
int l;
|
||||
|
||||
l = 0;
|
||||
switch(key->public_key.algorithm)
|
||||
{
|
||||
case OPS_PKA_RSA:
|
||||
|
@ -124,11 +124,12 @@ ops_boolean_t ops_rsa_encrypt_mpi(const unsigned char *encoded_m_buf,
|
||||
const ops_public_key_t *pkey,
|
||||
ops_pk_session_key_parameters_t *skp)
|
||||
{
|
||||
assert(sz_encoded_m_buf==(size_t) BN_num_bytes(pkey->key.rsa.n));
|
||||
|
||||
unsigned char encmpibuf[8192];
|
||||
int n=0;
|
||||
|
||||
assert(sz_encoded_m_buf==(size_t) BN_num_bytes(pkey->key.rsa.n));
|
||||
|
||||
n=ops_rsa_public_encrypt(encmpibuf, encoded_m_buf, sz_encoded_m_buf, &pkey->key.rsa);
|
||||
assert(n!=-1);
|
||||
|
||||
@ -170,6 +171,10 @@ ops_boolean_t ops_encrypt_file(const char* input_filename, const char* output_fi
|
||||
|
||||
ops_create_info_t *cinfo;
|
||||
|
||||
unsigned char* buf;
|
||||
size_t bufsz;
|
||||
int done;
|
||||
|
||||
#ifdef WIN32
|
||||
fd_in=open(input_filename,O_RDONLY | O_BINARY);
|
||||
#else
|
||||
@ -194,15 +199,15 @@ ops_boolean_t ops_encrypt_file(const char* input_filename, const char* output_fi
|
||||
|
||||
// Do the writing
|
||||
|
||||
unsigned char* buf=NULL;
|
||||
size_t bufsz=16;
|
||||
int done=0;
|
||||
buf=NULL;
|
||||
bufsz=16;
|
||||
done=0;
|
||||
for (;;)
|
||||
{
|
||||
buf=realloc(buf,done+bufsz);
|
||||
|
||||
int n=0;
|
||||
|
||||
buf=realloc(buf,done+bufsz);
|
||||
|
||||
n=read(fd_in,buf+done,bufsz);
|
||||
if (!n)
|
||||
break;
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <openpgpsdk/hash.h>
|
||||
#include <openpgpsdk/final.h>
|
||||
|
||||
static int debug=0;
|
||||
|
@ -41,7 +41,7 @@
|
||||
|
||||
static int debug=0;
|
||||
|
||||
void test_secret_key(const ops_secret_key_t *skey)
|
||||
static void test_secret_key(const ops_secret_key_t *skey)
|
||||
{
|
||||
RSA* test=RSA_new();
|
||||
|
||||
@ -388,6 +388,7 @@ ops_boolean_t ops_dsa_verify(const unsigned char *hash,size_t hash_length,
|
||||
DSA_SIG *osig;
|
||||
DSA *odsa;
|
||||
int ret;
|
||||
unsigned int qlen;
|
||||
|
||||
osig=DSA_SIG_new();
|
||||
osig->r=sig->r;
|
||||
@ -401,8 +402,8 @@ ops_boolean_t ops_dsa_verify(const unsigned char *hash,size_t hash_length,
|
||||
|
||||
if (debug)
|
||||
{
|
||||
fprintf(stderr,"hash passed in:\n");
|
||||
unsigned i;
|
||||
fprintf(stderr,"hash passed in:\n");
|
||||
for (i=0; i<hash_length; i++)
|
||||
{
|
||||
fprintf(stderr,"%02x ", hash[i]);
|
||||
@ -411,7 +412,7 @@ ops_boolean_t ops_dsa_verify(const unsigned char *hash,size_t hash_length,
|
||||
}
|
||||
//printf("hash_length=%ld\n", hash_length);
|
||||
//printf("Q=%d\n", BN_num_bytes(odsa->q));
|
||||
unsigned int qlen=BN_num_bytes(odsa->q);
|
||||
qlen=BN_num_bytes(odsa->q);
|
||||
if (qlen < hash_length)
|
||||
hash_length=qlen;
|
||||
// ret=DSA_do_verify(hash,hash_length,osig,odsa);
|
||||
@ -637,6 +638,8 @@ ops_boolean_t ops_rsa_generate_keypair(const int numbits, const unsigned long e,
|
||||
ops_secret_key_t *skey=NULL;
|
||||
RSA *rsa=NULL;
|
||||
BN_CTX *ctx=BN_CTX_new();
|
||||
ops_create_info_t *cinfo;
|
||||
ops_memory_t *mem;
|
||||
|
||||
ops_keydata_init(keydata,OPS_PTAG_CT_SECRET_KEY);
|
||||
skey=ops_get_writable_secret_key_from_data(keydata);
|
||||
@ -677,8 +680,8 @@ ops_boolean_t ops_rsa_generate_keypair(const int numbits, const unsigned long e,
|
||||
|
||||
// Generate checksum
|
||||
|
||||
ops_create_info_t *cinfo=NULL;
|
||||
ops_memory_t *mem=NULL;
|
||||
cinfo=NULL;
|
||||
mem=NULL;
|
||||
|
||||
ops_setup_memory_write(&cinfo, &mem, 128);
|
||||
|
||||
|
@ -727,7 +727,7 @@ void ops_packet_free(ops_packet_t *packet)
|
||||
\ingroup Core_Create
|
||||
\brief Free allocated memory
|
||||
*/
|
||||
void ops_headers_free(ops_headers_t *headers)
|
||||
static void ops_headers_free(ops_headers_t *headers)
|
||||
{
|
||||
unsigned n;
|
||||
|
||||
@ -744,7 +744,7 @@ void ops_headers_free(ops_headers_t *headers)
|
||||
\ingroup Core_Create
|
||||
\brief Free allocated memory
|
||||
*/
|
||||
void ops_signed_cleartext_trailer_free(ops_signed_cleartext_trailer_t *trailer)
|
||||
static void ops_signed_cleartext_trailer_free(ops_signed_cleartext_trailer_t *trailer)
|
||||
{
|
||||
free(trailer->hash);
|
||||
trailer->hash=NULL;
|
||||
@ -754,7 +754,7 @@ void ops_signed_cleartext_trailer_free(ops_signed_cleartext_trailer_t *trailer)
|
||||
\ingroup Core_Create
|
||||
\brief Free allocated memory
|
||||
*/
|
||||
void ops_cmd_get_passphrase_free(ops_secret_key_passphrase_t *skp)
|
||||
static void ops_cmd_get_passphrase_free(ops_secret_key_passphrase_t *skp)
|
||||
{
|
||||
if (skp->passphrase && *skp->passphrase)
|
||||
{
|
||||
@ -1224,7 +1224,7 @@ static int parse_user_id(ops_region_t *region,ops_parse_info_t *pinfo)
|
||||
* \brief Free the memory used when parsing a private/experimental PKA signature
|
||||
* \param unknown_sig
|
||||
*/
|
||||
void free_unknown_sig_pka(ops_unknown_signature_t *unknown_sig)
|
||||
static void free_unknown_sig_pka(ops_unknown_signature_t *unknown_sig)
|
||||
{
|
||||
data_free(&unknown_sig->data);
|
||||
}
|
||||
@ -2601,8 +2601,8 @@ static int parse_pk_session_key(ops_region_t *region,
|
||||
|
||||
if (debug)
|
||||
{
|
||||
printf("session key recovered (len=%d):\n",k);
|
||||
unsigned int j;
|
||||
printf("session key recovered (len=%d):\n",k);
|
||||
for(j=0; j<k; j++)
|
||||
printf("%2x ", C.pk_session_key.key[j]);
|
||||
printf("\n");
|
||||
@ -2636,8 +2636,7 @@ static int parse_pk_session_key(ops_region_t *region,
|
||||
return 1;
|
||||
}
|
||||
|
||||
// XXX: make this static?
|
||||
int ops_decrypt_se_data(ops_content_tag_t tag,ops_region_t *region,
|
||||
static int ops_decrypt_se_data(ops_content_tag_t tag,ops_region_t *region,
|
||||
ops_parse_info_t *pinfo)
|
||||
{
|
||||
int r=1;
|
||||
@ -2702,7 +2701,7 @@ int ops_decrypt_se_data(ops_content_tag_t tag,ops_region_t *region,
|
||||
return r;
|
||||
}
|
||||
|
||||
int ops_decrypt_se_ip_data(ops_content_tag_t tag,ops_region_t *region,
|
||||
static int ops_decrypt_se_ip_data(ops_content_tag_t tag,ops_region_t *region,
|
||||
ops_parse_info_t *pinfo)
|
||||
{
|
||||
int r=1;
|
||||
@ -2842,6 +2841,7 @@ static int ops_parse_one_packet(ops_parse_info_t *pinfo,
|
||||
{
|
||||
ops_boolean_t rb;
|
||||
|
||||
rb = ops_false;
|
||||
C.ptag.content_tag=(*ptag&OPS_PTAG_OF_CONTENT_TAG_MASK)
|
||||
>> OPS_PTAG_OF_CONTENT_TAG_SHIFT;
|
||||
C.ptag.length_type=*ptag&OPS_PTAG_OF_LENGTH_TYPE_MASK;
|
||||
|
@ -47,7 +47,7 @@ static void print_hexdump(const char *name,
|
||||
static void print_hexdump_data(const char *name,
|
||||
const unsigned char *data,
|
||||
unsigned int len);
|
||||
static void print_indent();
|
||||
static void print_indent(void);
|
||||
static void print_name(const char *name);
|
||||
static void print_string_and_value(char *name,
|
||||
const char *str,
|
||||
@ -217,7 +217,7 @@ ops_print_secret_key_verbose(const ops_secret_key_t* skey)
|
||||
\param type
|
||||
\param skey
|
||||
*/
|
||||
void
|
||||
static void
|
||||
ops_print_secret_key_verbose(const ops_content_tag_t type, const ops_secret_key_t* skey)
|
||||
{
|
||||
printf("------- SECRET KEY or ENCRYPTED SECRET KEY ------\n");
|
||||
@ -367,7 +367,7 @@ static void print_name(const char *name)
|
||||
printf("%s: ",name);
|
||||
}
|
||||
|
||||
static void print_indent()
|
||||
static void print_indent(void)
|
||||
{
|
||||
int i=0;
|
||||
|
||||
@ -384,7 +384,7 @@ static void print_hex(const unsigned char *src,size_t length)
|
||||
|
||||
static void showtime(const char *name,time_t t)
|
||||
{
|
||||
printf("%s=" TIME_T_FMT " (%.24s)",name,t,ctime(&t));
|
||||
printf("%s=" TIME_T_FMT " (%.24s)",name,(long long)t,ctime(&t));
|
||||
}
|
||||
static void showtime_short(time_t t)
|
||||
{
|
||||
@ -456,7 +456,7 @@ static void print_duration(char *name, time_t time)
|
||||
|
||||
print_indent();
|
||||
printf("%s: ",name);
|
||||
printf("duration " TIME_T_FMT " seconds",time);
|
||||
printf("duration " TIME_T_FMT " seconds",(long long)time);
|
||||
|
||||
mins=time/60;
|
||||
hours=mins/60;
|
||||
@ -610,7 +610,7 @@ static void start_subpacket(unsigned type)
|
||||
type-OPS_PTAG_SIGNATURE_SUBPACKET_BASE);
|
||||
}
|
||||
|
||||
static void end_subpacket()
|
||||
static void end_subpacket(void)
|
||||
{
|
||||
indent--;
|
||||
}
|
||||
@ -1000,7 +1000,7 @@ int ops_print_packet(const ops_parser_content_t *content_)
|
||||
|
||||
case OPS_PTAG_SS_EMBEDDED_SIGNATURE:
|
||||
start_subpacket(content_->tag);
|
||||
end_subpacket(content_->tag); // \todo print out contents?
|
||||
end_subpacket(); // \todo print out contents?
|
||||
break;
|
||||
|
||||
case OPS_PTAG_SS_USERDEFINED00:
|
||||
|
@ -317,7 +317,7 @@ static int unarmoured_read_char(dearmour_arg_t *arg,ops_error_t **errors,
|
||||
*
|
||||
* \return header value if found, otherwise NULL
|
||||
*/
|
||||
const char *ops_find_header(ops_headers_t *headers,const char *key)
|
||||
static const char *ops_find_header(ops_headers_t *headers,const char *key)
|
||||
{
|
||||
unsigned n;
|
||||
|
||||
@ -331,7 +331,7 @@ const char *ops_find_header(ops_headers_t *headers,const char *key)
|
||||
* \param dest
|
||||
* \param src
|
||||
*/
|
||||
void ops_dup_headers(ops_headers_t *dest,const ops_headers_t *src)
|
||||
static void ops_dup_headers(ops_headers_t *dest,const ops_headers_t *src)
|
||||
{
|
||||
unsigned n;
|
||||
|
||||
|
@ -66,6 +66,7 @@ static int encrypted_data_reader(void *dest,size_t length,ops_error_t **errors,
|
||||
{
|
||||
encrypted_arg_t *arg=ops_reader_get_arg(rinfo);
|
||||
int saved=length;
|
||||
char *cdest;
|
||||
|
||||
// V3 MPIs have the count plain and the cipher is reset after each count
|
||||
if(arg->prev_read_was_plain && !rinfo->pinfo->reading_mpi_length)
|
||||
@ -104,6 +105,10 @@ static int encrypted_data_reader(void *dest,size_t length,ops_error_t **errors,
|
||||
length-=n;
|
||||
#ifdef WIN32
|
||||
(char*)dest+=n;
|
||||
#elif defined(__NetBSD__)
|
||||
cdest = dest;
|
||||
cdest+=n;
|
||||
dest = cdest;
|
||||
#else
|
||||
dest+=n;
|
||||
#endif
|
||||
@ -152,8 +157,8 @@ static int encrypted_data_reader(void *dest,size_t length,ops_error_t **errors,
|
||||
|
||||
if (debug)
|
||||
{
|
||||
fprintf(stderr,"READING:\nencrypted: ");
|
||||
int i=0;
|
||||
fprintf(stderr,"READING:\nencrypted: ");
|
||||
for (i=0; i<16; i++)
|
||||
fprintf(stderr,"%2x ", buffer[i]);
|
||||
fprintf(stderr,"\n");
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include <openpgpsdk/crypto.h>
|
||||
#include <openpgpsdk/create.h>
|
||||
#include <openpgpsdk/errors.h>
|
||||
#include <openpgpsdk/readerwriter.h>
|
||||
#include <stdio.h>
|
||||
#include <assert.h>
|
||||
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include <openpgpsdk/crypto.h>
|
||||
#include <openpgpsdk/create.h>
|
||||
#include <openpgpsdk/errors.h>
|
||||
#include <openpgpsdk/readerwriter.h>
|
||||
#include <stdio.h>
|
||||
#include <assert.h>
|
||||
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include <openpgpsdk/crypto.h>
|
||||
#include <openpgpsdk/create.h>
|
||||
#include <openpgpsdk/writer_armoured.h>
|
||||
#include <openpgpsdk/validate.h>
|
||||
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
@ -88,6 +89,7 @@ static unsigned char prefix_sha256[]={ 0x30,0x31,0x30,0x0d,0x06,0x09,0x60,0x86,
|
||||
0x48,0x01,0x65,0x03,0x04,0x02,0x01,0x05,
|
||||
0x00,0x04,0x20 };
|
||||
|
||||
#if 0
|
||||
/**
|
||||
\ingroup Core_Create
|
||||
implementation of EMSA-PKCS1-v1_5, as defined in OpenPGP RFC
|
||||
@ -97,7 +99,7 @@ static unsigned char prefix_sha256[]={ 0x30,0x31,0x30,0x0d,0x06,0x09,0x60,0x86,
|
||||
\param EM
|
||||
\return ops_true if OK; else ops_false
|
||||
*/
|
||||
ops_boolean_t encode_hash_buf(const unsigned char *M, size_t mLen,
|
||||
static ops_boolean_t encode_hash_buf(const unsigned char *M, size_t mLen,
|
||||
const ops_hash_algorithm_t hash_alg,
|
||||
unsigned char* EM
|
||||
)
|
||||
@ -178,6 +180,7 @@ ops_boolean_t encode_hash_buf(const unsigned char *M, size_t mLen,
|
||||
|
||||
return ops_true;
|
||||
}
|
||||
#endif
|
||||
|
||||
// XXX: both this and verify would be clearer if the signature were
|
||||
// treated as an MPI.
|
||||
@ -233,6 +236,7 @@ static void dsa_sign(ops_hash_t *hash,
|
||||
unsigned char hashbuf[8192];
|
||||
unsigned hashsize;
|
||||
unsigned t;
|
||||
DSA_SIG* dsasig;
|
||||
|
||||
// hashsize must be "equal in size to the number of bits of q,
|
||||
// the group generated by the DSA key's generator value
|
||||
@ -247,7 +251,6 @@ static void dsa_sign(ops_hash_t *hash,
|
||||
ops_write(&hashbuf[0],2,cinfo);
|
||||
|
||||
// write signature to buf
|
||||
DSA_SIG* dsasig;
|
||||
dsasig=ops_dsa_sign(hashbuf,hashsize,sdsa,dsa);
|
||||
|
||||
// convert and write the sig out to memory
|
||||
@ -267,7 +270,10 @@ static ops_boolean_t rsa_verify(ops_hash_algorithm_t type,
|
||||
unsigned keysize;
|
||||
unsigned char *prefix;
|
||||
int plen;
|
||||
int debug_len_decrypted;
|
||||
|
||||
plen = 0;
|
||||
prefix = (unsigned char *) "";
|
||||
keysize=BN_num_bytes(rsa->n);
|
||||
/* RSA key can't be bigger than 65535 bits, so... */
|
||||
assert(keysize <= sizeof hashbuf_from_sig);
|
||||
@ -275,7 +281,7 @@ static ops_boolean_t rsa_verify(ops_hash_algorithm_t type,
|
||||
BN_bn2bin(sig->sig,sigbuf);
|
||||
|
||||
n=ops_rsa_public_decrypt(hashbuf_from_sig,sigbuf,(BN_num_bits(sig->sig)+7)/8,rsa);
|
||||
int debug_len_decrypted=n;
|
||||
debug_len_decrypted=n;
|
||||
|
||||
if(n != keysize) // obviously, this includes error returns
|
||||
return ops_false;
|
||||
@ -306,6 +312,7 @@ static ops_boolean_t rsa_verify(ops_hash_algorithm_t type,
|
||||
if (debug)
|
||||
{
|
||||
int zz;
|
||||
unsigned uu;
|
||||
|
||||
printf("\n");
|
||||
printf("hashbuf_from_sig\n");
|
||||
@ -319,7 +326,6 @@ static ops_boolean_t rsa_verify(ops_hash_algorithm_t type,
|
||||
|
||||
printf("\n");
|
||||
printf("hash from sig\n");
|
||||
unsigned uu;
|
||||
for (uu=0; uu<hash_length; uu++)
|
||||
{ printf("%02x ", hashbuf_from_sig[n+plen+uu]); }
|
||||
printf("\n");
|
||||
@ -403,6 +409,7 @@ ops_boolean_t ops_check_signature(const unsigned char *hash,unsigned length,
|
||||
hexdump(hash,length);
|
||||
*/
|
||||
|
||||
ret = 0;
|
||||
switch(sig->info.key_algorithm)
|
||||
{
|
||||
case OPS_PKA_DSA:
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include <openpgpsdk/crypto.h>
|
||||
#include <openpgpsdk/create.h>
|
||||
#include <openpgpsdk/errors.h>
|
||||
#include <openpgpsdk/readerwriter.h>
|
||||
#include <stdio.h>
|
||||
#include <assert.h>
|
||||
|
||||
|
@ -382,8 +382,8 @@ validate_data_cb(const ops_parser_content_t *content_,ops_parse_cb_info_t *cbinf
|
||||
|
||||
if (debug)
|
||||
{
|
||||
printf("\n*** hashed data:\n");
|
||||
unsigned int zzz=0;
|
||||
printf("\n*** hashed data:\n");
|
||||
for (zzz=0; zzz<content->signature.info.v4_hashed_data_length; zzz++)
|
||||
printf("0x%02x ", content->signature.info.v4_hashed_data[zzz]);
|
||||
printf("\n");
|
||||
|
@ -382,6 +382,8 @@ static ops_boolean_t armoured_finaliser(ops_armor_type_t type, ops_error_t **err
|
||||
|
||||
char* tail=NULL;
|
||||
unsigned int sz_tail=0;
|
||||
base64_arg_t *arg;
|
||||
unsigned char c[3];
|
||||
|
||||
switch(type)
|
||||
{
|
||||
@ -399,8 +401,7 @@ static ops_boolean_t armoured_finaliser(ops_armor_type_t type, ops_error_t **err
|
||||
assert(0);
|
||||
}
|
||||
|
||||
base64_arg_t *arg=ops_writer_get_arg(winfo);
|
||||
unsigned char c[3];
|
||||
arg=ops_writer_get_arg(winfo);
|
||||
|
||||
if(arg->pos)
|
||||
{
|
||||
@ -455,7 +456,9 @@ void ops_writer_push_armoured(ops_create_info_t *info, ops_armor_type_t type)
|
||||
char* header=NULL;
|
||||
unsigned int sz_hdr=0;
|
||||
ops_boolean_t (* finaliser)(ops_error_t **errors, ops_writer_info_t *winfo);
|
||||
base64_arg_t *arg;
|
||||
|
||||
finaliser = NULL;
|
||||
switch(type)
|
||||
{
|
||||
case OPS_PGP_PUBLIC_KEY_BLOCK:
|
||||
@ -479,7 +482,7 @@ void ops_writer_push_armoured(ops_create_info_t *info, ops_armor_type_t type)
|
||||
ops_writer_push(info,linebreak_writer,NULL,ops_writer_generic_destroyer,
|
||||
ops_mallocz(sizeof(linebreak_arg_t)));
|
||||
|
||||
base64_arg_t *arg=ops_mallocz(sizeof *arg);
|
||||
arg=ops_mallocz(sizeof *arg);
|
||||
arg->checksum=CRC24_INIT;
|
||||
ops_writer_push(info,base64_writer,finaliser,ops_writer_generic_destroyer,arg);
|
||||
}
|
||||
|
@ -23,6 +23,7 @@
|
||||
*/
|
||||
|
||||
#include <openpgpsdk/create.h>
|
||||
#include <openpgpsdk/readerwriter.h>
|
||||
|
||||
#include <openpgpsdk/final.h>
|
||||
|
||||
|
@ -36,6 +36,7 @@
|
||||
#include <openpgpsdk/keyring.h>
|
||||
#include <openpgpsdk/random.h>
|
||||
#include <openpgpsdk/readerwriter.h>
|
||||
#include <openpgpsdk/streamwriter.h>
|
||||
|
||||
#define MAX_PARTIAL_DATA_LENGTH 1073741824
|
||||
|
||||
@ -114,8 +115,7 @@ void ops_writer_push_stream_encrypt_se_ip(ops_create_info_t *cinfo,
|
||||
}
|
||||
|
||||
|
||||
|
||||
unsigned int ops_calc_partial_data_length(unsigned int len)
|
||||
static unsigned int ops_calc_partial_data_length(unsigned int len)
|
||||
{
|
||||
int i;
|
||||
unsigned int mask = MAX_PARTIAL_DATA_LENGTH;
|
||||
@ -133,7 +133,7 @@ unsigned int ops_calc_partial_data_length(unsigned int len)
|
||||
return mask;
|
||||
}
|
||||
|
||||
ops_boolean_t ops_write_partial_data_length(unsigned int len,
|
||||
static ops_boolean_t ops_write_partial_data_length(unsigned int len,
|
||||
ops_create_info_t *info)
|
||||
{
|
||||
// len must be a power of 2 from 0 to 30
|
||||
@ -148,7 +148,7 @@ ops_boolean_t ops_write_partial_data_length(unsigned int len,
|
||||
return ops_write(c,1,info);
|
||||
}
|
||||
|
||||
ops_boolean_t ops_stream_write_literal_data(const unsigned char *data,
|
||||
static ops_boolean_t ops_stream_write_literal_data(const unsigned char *data,
|
||||
unsigned int len,
|
||||
ops_create_info_t *info)
|
||||
{
|
||||
@ -162,7 +162,8 @@ ops_boolean_t ops_stream_write_literal_data(const unsigned char *data,
|
||||
return ops_true;
|
||||
}
|
||||
|
||||
ops_boolean_t ops_stream_write_literal_data_first(const unsigned char *data,
|
||||
static ops_boolean_t
|
||||
ops_stream_write_literal_data_first(const unsigned char *data,
|
||||
unsigned int len,
|
||||
const ops_literal_data_type_t type,
|
||||
ops_create_info_t *info)
|
||||
@ -189,7 +190,8 @@ ops_boolean_t ops_stream_write_literal_data_first(const unsigned char *data,
|
||||
return ops_true;
|
||||
}
|
||||
|
||||
ops_boolean_t ops_stream_write_literal_data_last(const unsigned char *data,
|
||||
static ops_boolean_t
|
||||
ops_stream_write_literal_data_last(const unsigned char *data,
|
||||
unsigned int len,
|
||||
ops_create_info_t *info)
|
||||
{
|
||||
@ -198,7 +200,8 @@ ops_boolean_t ops_stream_write_literal_data_last(const unsigned char *data,
|
||||
return ops_true;
|
||||
}
|
||||
|
||||
ops_boolean_t ops_stream_write_se_ip(const unsigned char *data,
|
||||
static ops_boolean_t
|
||||
ops_stream_write_se_ip(const unsigned char *data,
|
||||
unsigned int len,
|
||||
stream_encrypt_se_ip_arg_t *arg,
|
||||
ops_create_info_t *cinfo)
|
||||
@ -219,7 +222,8 @@ ops_boolean_t ops_stream_write_se_ip(const unsigned char *data,
|
||||
return ops_true;
|
||||
}
|
||||
|
||||
ops_boolean_t ops_stream_write_se_ip_first(const unsigned char *data,
|
||||
static ops_boolean_t
|
||||
ops_stream_write_se_ip_first(const unsigned char *data,
|
||||
unsigned int len,
|
||||
stream_encrypt_se_ip_arg_t *arg,
|
||||
ops_create_info_t *cinfo)
|
||||
@ -262,7 +266,8 @@ ops_boolean_t ops_stream_write_se_ip_first(const unsigned char *data,
|
||||
return ops_true;
|
||||
}
|
||||
|
||||
ops_boolean_t ops_stream_write_se_ip_last(const unsigned char *data,
|
||||
static ops_boolean_t
|
||||
ops_stream_write_se_ip_last(const unsigned char *data,
|
||||
unsigned int len,
|
||||
stream_encrypt_se_ip_arg_t *arg,
|
||||
ops_create_info_t *cinfo)
|
||||
|
24
crypto/external/bsd/openpgpsdk/lib/Makefile
vendored
Normal file
24
crypto/external/bsd/openpgpsdk/lib/Makefile
vendored
Normal file
@ -0,0 +1,24 @@
|
||||
# $NetBSD: Makefile,v 1.1 2009/01/20 07:12:16 agc Exp $
|
||||
|
||||
.include <bsd.own.mk>
|
||||
|
||||
#USE_FORT?= yes # network protocol library
|
||||
USE_FORT?= no # network protocol library
|
||||
|
||||
LIB= openpgpsdk
|
||||
SRCS+= accumulate.c compress.c create.c crypto.c errors.c fingerprint.c
|
||||
SRCS+= hash.c keyring.c lists.c memory.c openssl_crypto.c packet-parse.c
|
||||
SRCS+= packet-print.c packet-show.c random.c reader.c reader_armoured.c
|
||||
SRCS+= reader_encrypted_se.c reader_encrypted_seip.c reader_fd.c
|
||||
SRCS+= reader_hashed.c reader_mem.c readerwriter.c signature.c symmetric.c
|
||||
SRCS+= util.c validate.c writer.c writer_armour.c writer_encrypt.c
|
||||
SRCS+= writer_encrypt_se_ip.c writer_fd.c writer_memory.c
|
||||
SRCS+= writer_skey_checksum.c writer_stream_encrypt_se_ip.c
|
||||
CPPFLAGS+= -I${EXTDIST}/include
|
||||
NOMAN= # defined
|
||||
WARNS=1
|
||||
|
||||
EXTDIST= ${NETBSDSRCDIR}/crypto/external/bsd/openpgpsdk/dist
|
||||
.PATH: ${EXTDIST}/src/lib
|
||||
|
||||
.include <bsd.lib.mk>
|
13
crypto/external/lib/Makefile
vendored
Normal file
13
crypto/external/lib/Makefile
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
# $NetBSD: Makefile,v 1.1 2009/01/20 07:12:16 agc Exp $
|
||||
|
||||
#
|
||||
# This Makefile exists to provide a single point to build
|
||||
# all crypto libraries provided by external packages that may
|
||||
# be used by other applications in the system.
|
||||
#
|
||||
|
||||
.include <bsd.own.mk>
|
||||
|
||||
SUBDIR+= ../bsd/openpgpsdk/lib
|
||||
|
||||
.include <bsd.subdir.mk>
|
Loading…
x
Reference in New Issue
Block a user