mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-11-29 03:46:46 -05:00
added compilable version of openpgp sdk
git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-OpenPGP@5048 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
8cb15bdbef
commit
7d06d19e40
67 changed files with 20945 additions and 0 deletions
33
openpgpsdk/include/openpgpsdk/accumulate.h
Normal file
33
openpgpsdk/include/openpgpsdk/accumulate.h
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
/*
|
||||
* Copyright (c) 2005-2008 Nominet UK (www.nic.uk)
|
||||
* All rights reserved.
|
||||
* Contributors: Ben Laurie, Rachel Willmer. The Contributors have asserted
|
||||
* their moral rights under the UK Copyright Design and Patents Act 1988 to
|
||||
* be recorded as the authors of this copyright work.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||
* use this file except in compliance with the License.
|
||||
*
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
*/
|
||||
|
||||
#ifndef OPS_ACCUMULATE_H
|
||||
#define OPS_ACCUMULATE_H
|
||||
#endif
|
||||
|
||||
#include "keyring.h"
|
||||
#include "packet-parse.h"
|
||||
|
||||
int ops_parse_and_accumulate(ops_keyring_t *keyring,
|
||||
ops_parse_info_t *parse_info);
|
||||
54
openpgpsdk/include/openpgpsdk/armour.h
Normal file
54
openpgpsdk/include/openpgpsdk/armour.h
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
/*
|
||||
* Copyright (c) 2005-2008 Nominet UK (www.nic.uk)
|
||||
* All rights reserved.
|
||||
* Contributors: Ben Laurie, Rachel Willmer. The Contributors have asserted
|
||||
* their moral rights under the UK Copyright Design and Patents Act 1988 to
|
||||
* be recorded as the authors of this copyright work.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||
* use this file except in compliance with the License.
|
||||
*
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef __OPS_ARMOUR_H__
|
||||
#define __OPS_ARMOUR_H__
|
||||
|
||||
#include "packet-parse.h"
|
||||
#include "signature.h"
|
||||
|
||||
unsigned ops_crc24(unsigned checksum,unsigned char c);
|
||||
|
||||
void ops_reader_push_dearmour(ops_parse_info_t *parse_info);
|
||||
|
||||
void ops_reader_pop_dearmour(ops_parse_info_t *parse_info);
|
||||
ops_boolean_t ops_writer_push_clearsigned(ops_create_info_t *info,
|
||||
ops_create_signature_t *sig);
|
||||
void ops_writer_push_armoured_message(ops_create_info_t *info);
|
||||
ops_boolean_t ops_writer_switch_to_armoured_signature(ops_create_info_t *info);
|
||||
|
||||
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;
|
||||
|
||||
void ops_writer_push_armoured(ops_create_info_t *info, ops_armor_type_t type);
|
||||
|
||||
#define CRC24_INIT 0xb704ceL
|
||||
|
||||
#endif /* __OPS_ARMOUR_H__ */
|
||||
|
||||
// EOF
|
||||
37
openpgpsdk/include/openpgpsdk/callback.h
Normal file
37
openpgpsdk/include/openpgpsdk/callback.h
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
* Copyright (c) 2005-2008 Nominet UK (www.nic.uk)
|
||||
* All rights reserved.
|
||||
* Contributors: Ben Laurie, Rachel Willmer. The Contributors have asserted
|
||||
* their moral rights under the UK Copyright Design and Patents Act 1988 to
|
||||
* be recorded as the authors of this copyright work.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||
* use this file except in compliance with the License.
|
||||
*
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef __OPS_CALLBACK_H__
|
||||
#define __OPS_CALLBACK_H__
|
||||
|
||||
#define CB(cbinfo,t,pc) do { (pc)->tag=(t); if(ops_parse_cb((pc),(cbinfo)) == OPS_RELEASE_MEMORY) ops_parser_content_free(pc); } while(0)
|
||||
/*#define CB(cbinfo,t,pc) do { (pc)->tag=(t); if((cbinfo)->cb(pc,(cbinfo)) == OPS_RELEASE_MEMORY) ops_parser_content_free(pc); } while(0)*/
|
||||
//#define CB(cbinfo,t,pc) do { (pc)->tag=(t); if((cbinfo)->cb(pc,(cbinfo)) == OPS_RELEASE_MEMORY) ops_parser_content_free(pc); } while(0)
|
||||
|
||||
#define CBP(info,t,pc) CB(&(info)->cbinfo,t,pc)
|
||||
|
||||
#define ERR(cbinfo,err,code) do { content.content.error.error=err; content.tag=OPS_PARSER_ERROR; ops_parse_cb(&content,(cbinfo)); OPS_ERROR(errors,code,err); return -1; } while(0)
|
||||
/*#define ERR(err) do { content.content.error.error=err; content.tag=OPS_PARSER_ERROR; ops_parse_cb(&content,cbinfo); return -1; } while(0)*/
|
||||
|
||||
#define ERRP(info,err) do { C.error.error=err; CBP(info,OPS_PARSER_ERROR,&content); return ops_false; } while(0)
|
||||
|
||||
|
||||
#endif /*__OPS_CALLBACK_H__*/
|
||||
32
openpgpsdk/include/openpgpsdk/compress.h
Normal file
32
openpgpsdk/include/openpgpsdk/compress.h
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
/*
|
||||
* Copyright (c) 2005-2008 Nominet UK (www.nic.uk)
|
||||
* All rights reserved.
|
||||
* Contributors: Ben Laurie, Rachel Willmer. The Contributors have asserted
|
||||
* their moral rights under the UK Copyright Design and Patents Act 1988 to
|
||||
* be recorded as the authors of this copyright work.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||
* use this file except in compliance with the License.
|
||||
*
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
*/
|
||||
|
||||
#include "packet-parse.h"
|
||||
|
||||
int ops_decompress(ops_region_t *region,ops_parse_info_t *parse_info,
|
||||
ops_compression_type_t type);
|
||||
|
||||
ops_boolean_t ops_write_compressed(const unsigned char* data,
|
||||
const unsigned int len,
|
||||
ops_create_info_t *cinfo);
|
||||
7
openpgpsdk/include/openpgpsdk/configure.h
Normal file
7
openpgpsdk/include/openpgpsdk/configure.h
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
/* generated by configure from include/openpgpsdk/configure.h.template. Don't edit. */
|
||||
|
||||
#define HAVE_ALLOCA_H 0
|
||||
#define TIME_T_FMT "%ld"
|
||||
|
||||
/* for silencing unused parameter warnings */
|
||||
#define OPS_USED(x) (x)=(x)
|
||||
82
openpgpsdk/include/openpgpsdk/create.h
Normal file
82
openpgpsdk/include/openpgpsdk/create.h
Normal file
|
|
@ -0,0 +1,82 @@
|
|||
/*
|
||||
* Copyright (c) 2005-2008 Nominet UK (www.nic.uk)
|
||||
* All rights reserved.
|
||||
* Contributors: Ben Laurie, Rachel Willmer. The Contributors have asserted
|
||||
* their moral rights under the UK Copyright Design and Patents Act 1988 to
|
||||
* be recorded as the authors of this copyright work.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||
* use this file except in compliance with the License.
|
||||
*
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
*/
|
||||
|
||||
#ifndef OPS_CREATE_H
|
||||
#define OPS_CREATE_H
|
||||
|
||||
#include <openpgpsdk/types.h>
|
||||
#include <openpgpsdk/packet.h>
|
||||
#include <openpgpsdk/crypto.h>
|
||||
#include <openpgpsdk/memory.h>
|
||||
#include <openpgpsdk/errors.h>
|
||||
#include <openpgpsdk/keyring.h>
|
||||
#include <openpgpsdk/writer.h>
|
||||
|
||||
/**
|
||||
* \ingroup Create
|
||||
* This struct contains the required information about how to write this stream
|
||||
*/
|
||||
struct ops_create_info
|
||||
{
|
||||
ops_writer_info_t winfo;
|
||||
ops_error_t *errors; /*!< an error stack */
|
||||
};
|
||||
|
||||
ops_create_info_t *ops_create_info_new(void);
|
||||
void ops_create_info_delete(ops_create_info_t *info);
|
||||
|
||||
ops_memory_t* ops_write_mem_from_file(const char *filename, int* errnum);
|
||||
int ops_write_file_from_buf(const char *filename, const char* buf, const size_t len, const ops_boolean_t overwrite);
|
||||
|
||||
ops_boolean_t ops_calc_session_key_checksum(ops_pk_session_key_t *session_key, unsigned char *cs);
|
||||
void ops_build_public_key(ops_memory_t *out,const ops_public_key_t *key,
|
||||
ops_boolean_t make_packet);
|
||||
ops_boolean_t ops_write_struct_user_id(ops_user_id_t *id,
|
||||
ops_create_info_t *info);
|
||||
ops_boolean_t ops_write_struct_public_key(const ops_public_key_t *key,
|
||||
ops_create_info_t *info);
|
||||
|
||||
ops_boolean_t ops_write_ss_header(unsigned length,ops_content_tag_t type,
|
||||
ops_create_info_t *info);
|
||||
ops_boolean_t ops_write_struct_secret_key(const ops_secret_key_t *key,
|
||||
const unsigned char* passphrase,
|
||||
const size_t pplen,
|
||||
ops_create_info_t *info);
|
||||
ops_boolean_t ops_write_one_pass_sig(const ops_secret_key_t* skey,
|
||||
const ops_hash_algorithm_t hash_alg,
|
||||
const ops_sig_type_t sig_type,
|
||||
ops_create_info_t* info);
|
||||
ops_boolean_t ops_write_literal_data_from_buf(const unsigned char *data,
|
||||
const int maxlen,
|
||||
const ops_literal_data_type_t type,
|
||||
ops_create_info_t *info);
|
||||
ops_pk_session_key_t *ops_create_pk_session_key(const ops_keydata_t *key);
|
||||
ops_boolean_t ops_write_pk_session_key(ops_create_info_t *info,
|
||||
ops_pk_session_key_t *pksk);
|
||||
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);
|
||||
|
||||
#endif /*OPS_CREATE_H*/
|
||||
|
||||
// eof
|
||||
176
openpgpsdk/include/openpgpsdk/crypto.h
Normal file
176
openpgpsdk/include/openpgpsdk/crypto.h
Normal file
|
|
@ -0,0 +1,176 @@
|
|||
/*
|
||||
* Copyright (c) 2005-2008 Nominet UK (www.nic.uk)
|
||||
* All rights reserved.
|
||||
* Contributors: Ben Laurie, Rachel Willmer. The Contributors have asserted
|
||||
* their moral rights under the UK Copyright Design and Patents Act 1988 to
|
||||
* be recorded as the authors of this copyright work.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||
* use this file except in compliance with the License.
|
||||
*
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
*/
|
||||
|
||||
#ifndef OPS_CRYPTO_H
|
||||
#define OPS_CRYPTO_H
|
||||
|
||||
#include "keyring.h"
|
||||
#include "util.h"
|
||||
#include "packet.h"
|
||||
#include "packet-parse.h"
|
||||
#include <openssl/dsa.h>
|
||||
|
||||
#define OPS_MIN_HASH_SIZE 16
|
||||
|
||||
typedef void ops_hash_init_t(ops_hash_t *hash);
|
||||
typedef void ops_hash_add_t(ops_hash_t *hash,const unsigned char *data,
|
||||
unsigned length);
|
||||
typedef unsigned ops_hash_finish_t(ops_hash_t *hash,unsigned char *out);
|
||||
|
||||
/** _ops_hash_t */
|
||||
struct _ops_hash_t
|
||||
{
|
||||
ops_hash_algorithm_t algorithm;
|
||||
size_t size;
|
||||
const char *name;
|
||||
ops_hash_init_t *init;
|
||||
ops_hash_add_t *add;
|
||||
ops_hash_finish_t *finish;
|
||||
void *data;
|
||||
};
|
||||
|
||||
typedef void ops_crypt_set_iv_t(ops_crypt_t *crypt,
|
||||
const unsigned char *iv);
|
||||
typedef void ops_crypt_set_key_t(ops_crypt_t *crypt,
|
||||
const unsigned char *key);
|
||||
typedef void ops_crypt_init_t(ops_crypt_t *crypt);
|
||||
typedef void ops_crypt_resync_t(ops_crypt_t *crypt);
|
||||
typedef void ops_crypt_block_encrypt_t(ops_crypt_t *crypt,void *out,
|
||||
const void *in);
|
||||
typedef void ops_crypt_block_decrypt_t(ops_crypt_t *crypt,void *out,
|
||||
const void *in);
|
||||
typedef void ops_crypt_cfb_encrypt_t(ops_crypt_t *crypt,void *out,
|
||||
const void *in, size_t count);
|
||||
typedef void ops_crypt_cfb_decrypt_t(ops_crypt_t *crypt,void *out,
|
||||
const void *in, size_t count);
|
||||
typedef void ops_crypt_finish_t(ops_crypt_t *crypt);
|
||||
|
||||
/** _ops_crypt_t */
|
||||
struct _ops_crypt_t
|
||||
{
|
||||
ops_symmetric_algorithm_t algorithm;
|
||||
size_t blocksize;
|
||||
size_t keysize;
|
||||
ops_crypt_set_iv_t *set_iv; /* Call this before decrypt init! */
|
||||
ops_crypt_set_key_t *set_key; /* Call this before init! */
|
||||
ops_crypt_init_t *base_init;
|
||||
ops_crypt_resync_t *decrypt_resync;
|
||||
// encrypt/decrypt one block
|
||||
ops_crypt_block_encrypt_t *block_encrypt;
|
||||
ops_crypt_block_decrypt_t *block_decrypt;
|
||||
|
||||
// Standard CFB encrypt/decrypt (as used by Sym Enc Int Prot packets)
|
||||
ops_crypt_cfb_encrypt_t *cfb_encrypt;
|
||||
ops_crypt_cfb_decrypt_t *cfb_decrypt;
|
||||
|
||||
ops_crypt_finish_t *decrypt_finish;
|
||||
unsigned char iv[OPS_MAX_BLOCK_SIZE];
|
||||
unsigned char civ[OPS_MAX_BLOCK_SIZE];
|
||||
unsigned char siv[OPS_MAX_BLOCK_SIZE]; /* Needed for weird v3 resync */
|
||||
unsigned char key[OPS_MAX_KEY_SIZE];
|
||||
size_t num; /* Offset - see openssl _encrypt doco */
|
||||
void *encrypt_key;
|
||||
void *decrypt_key;
|
||||
};
|
||||
|
||||
void ops_crypto_init(void);
|
||||
void ops_crypto_finish(void);
|
||||
void ops_hash_md5(ops_hash_t *hash);
|
||||
void ops_hash_sha1(ops_hash_t *hash);
|
||||
void ops_hash_sha256(ops_hash_t *hash);
|
||||
void ops_hash_sha512(ops_hash_t *hash);
|
||||
void ops_hash_sha384(ops_hash_t *hash);
|
||||
void ops_hash_sha224(ops_hash_t *hash);
|
||||
void ops_hash_any(ops_hash_t *hash,ops_hash_algorithm_t alg);
|
||||
ops_hash_algorithm_t ops_hash_algorithm_from_text(const char *hash);
|
||||
const char *ops_text_from_hash(ops_hash_t *hash);
|
||||
unsigned ops_hash_size(ops_hash_algorithm_t alg);
|
||||
unsigned ops_hash(unsigned char *out,ops_hash_algorithm_t alg,const void *in,
|
||||
size_t length);
|
||||
|
||||
void ops_hash_add_int(ops_hash_t *hash,unsigned n,unsigned length);
|
||||
|
||||
ops_boolean_t ops_dsa_verify(const unsigned char *hash,size_t hash_length,
|
||||
const ops_dsa_signature_t *sig,
|
||||
const ops_dsa_public_key_t *dsa);
|
||||
int ops_rsa_public_decrypt(unsigned char *out,const unsigned char *in,
|
||||
size_t length,const ops_rsa_public_key_t *rsa);
|
||||
int ops_rsa_public_encrypt(unsigned char *out,const unsigned char *in,
|
||||
size_t length,const ops_rsa_public_key_t *rsa);
|
||||
int ops_rsa_private_encrypt(unsigned char *out,const unsigned char *in,
|
||||
size_t length,const ops_rsa_secret_key_t *srsa,
|
||||
const ops_rsa_public_key_t *rsa);
|
||||
int ops_rsa_private_decrypt(unsigned char *out,const unsigned char *in,
|
||||
size_t length,const ops_rsa_secret_key_t *srsa,
|
||||
const ops_rsa_public_key_t *rsa);
|
||||
|
||||
unsigned ops_block_size(ops_symmetric_algorithm_t alg);
|
||||
unsigned ops_key_size(ops_symmetric_algorithm_t alg);
|
||||
|
||||
int ops_decrypt_data(ops_content_tag_t tag,ops_region_t *region,
|
||||
ops_parse_info_t *parse_info);
|
||||
|
||||
int ops_crypt_any(ops_crypt_t *decrypt,ops_symmetric_algorithm_t alg);
|
||||
void ops_decrypt_init(ops_crypt_t *decrypt);
|
||||
void ops_encrypt_init(ops_crypt_t *encrypt);
|
||||
size_t ops_decrypt_se(ops_crypt_t *decrypt,void *out,const void *in,
|
||||
size_t count);
|
||||
size_t ops_encrypt_se(ops_crypt_t *encrypt,void *out,const void *in,
|
||||
size_t count);
|
||||
size_t ops_decrypt_se_ip(ops_crypt_t *decrypt,void *out,const void *in,
|
||||
size_t count);
|
||||
size_t ops_encrypt_se_ip(ops_crypt_t *encrypt,void *out,const void *in,
|
||||
size_t count);
|
||||
ops_boolean_t ops_is_sa_supported(ops_symmetric_algorithm_t alg);
|
||||
|
||||
void ops_reader_push_decrypt(ops_parse_info_t *pinfo,ops_crypt_t *decrypt,
|
||||
ops_region_t *region);
|
||||
void ops_reader_pop_decrypt(ops_parse_info_t *pinfo);
|
||||
|
||||
// Hash everything that's read
|
||||
void ops_reader_push_hash(ops_parse_info_t *pinfo,ops_hash_t *hash);
|
||||
void ops_reader_pop_hash(ops_parse_info_t *pinfo);
|
||||
|
||||
int ops_decrypt_and_unencode_mpi(unsigned char *buf,unsigned buflen,const BIGNUM *encmpi,
|
||||
const ops_secret_key_t *skey);
|
||||
ops_boolean_t ops_rsa_encrypt_mpi(const unsigned char *buf, const size_t buflen,
|
||||
const ops_public_key_t *pkey,
|
||||
ops_pk_session_key_parameters_t *spk);
|
||||
|
||||
|
||||
// Encrypt everything that's written
|
||||
struct ops_key_data;
|
||||
void ops_writer_push_encrypt(ops_create_info_t *info,
|
||||
const struct ops_key_data *key);
|
||||
|
||||
ops_boolean_t ops_encrypt_file(const char* input_filename, const char* output_filename, const ops_keydata_t *pub_key, const ops_boolean_t use_armour, const ops_boolean_t allow_overwrite);
|
||||
ops_boolean_t ops_decrypt_file(const char* input_filename, const char* output_filename, ops_keyring_t *keyring, const ops_boolean_t use_armour, const ops_boolean_t allow_overwrite,ops_parse_cb_t* cb_get_passphrase);
|
||||
|
||||
// Keys
|
||||
ops_boolean_t ops_rsa_generate_keypair(const int numbits, const unsigned long e, ops_keydata_t* keydata);
|
||||
ops_keydata_t* ops_rsa_create_selfsigned_keypair(const int numbits, const unsigned long e, ops_user_id_t * userid);
|
||||
|
||||
int ops_dsa_size(const ops_dsa_public_key_t *dsa);
|
||||
DSA_SIG* ops_dsa_sign(unsigned char* hashbuf, unsigned hashsize, const ops_dsa_secret_key_t *sdsa, const ops_dsa_public_key_t *dsa);
|
||||
#endif
|
||||
37
openpgpsdk/include/openpgpsdk/defs.h
Normal file
37
openpgpsdk/include/openpgpsdk/defs.h
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
* Copyright (c) 2005-2008 Nominet UK (www.nic.uk)
|
||||
* All rights reserved.
|
||||
* Contributors: Ben Laurie, Rachel Willmer. The Contributors have asserted
|
||||
* their moral rights under the UK Copyright Design and Patents Act 1988 to
|
||||
* be recorded as the authors of this copyright work.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||
* use this file except in compliance with the License.
|
||||
*
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
*/
|
||||
|
||||
#ifndef OPS_DEFS_H
|
||||
#define OPS_DEFS_H
|
||||
|
||||
#define OPS_ARMOURED ops_true
|
||||
#define OPS_UNARMOURED ops_false
|
||||
|
||||
#define OPS_OVERWRITE_YES ops_true
|
||||
#define OPS_OVERWRITE_NO ops_false
|
||||
|
||||
#define OPS_ACCUMULATE_YES ops_true
|
||||
#define OPS_ACCUMULATE_NO ops_false
|
||||
|
||||
#endif /* OPS_DEFS_H */
|
||||
125
openpgpsdk/include/openpgpsdk/errors.h
Normal file
125
openpgpsdk/include/openpgpsdk/errors.h
Normal file
|
|
@ -0,0 +1,125 @@
|
|||
/*
|
||||
* Copyright (c) 2005-2008 Nominet UK (www.nic.uk)
|
||||
* All rights reserved.
|
||||
* Contributors: Ben Laurie, Rachel Willmer. The Contributors have asserted
|
||||
* their moral rights under the UK Copyright Design and Patents Act 1988 to
|
||||
* be recorded as the authors of this copyright work.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||
* use this file except in compliance with the License.
|
||||
*
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
*/
|
||||
|
||||
#ifndef OPS_ERRORS
|
||||
#define OPS_ERRORS
|
||||
|
||||
#include "openpgpsdk/types.h"
|
||||
#include <errno.h>
|
||||
|
||||
/** 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 details */
|
||||
OPS_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 armour
|
||||
OPS_E_R_UNSUPPORTED =OPS_E_R+4,
|
||||
OPS_E_R_UNCONSUMED_DATA =OPS_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,
|
||||
|
||||
/* 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,
|
||||
|
||||
/* creator errors */
|
||||
OPS_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,
|
||||
|
||||
/* 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,
|
||||
|
||||
/* 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;
|
||||
|
||||
/** ops_errcode_name_map_t */
|
||||
typedef ops_map_t ops_errcode_name_map_t;
|
||||
|
||||
/** one entry in a linked list of errors */
|
||||
typedef struct ops_error
|
||||
{
|
||||
ops_errcode_t errcode;
|
||||
int sys_errno; /*!< irrelevent unless errcode == OPS_E_SYSTEM_ERROR */
|
||||
char *comment;
|
||||
const char *file;
|
||||
int line;
|
||||
struct ops_error *next;
|
||||
} ops_error_t;
|
||||
|
||||
char *ops_errcode(const ops_errcode_t errcode);
|
||||
|
||||
void ops_push_error(ops_error_t **errstack,ops_errcode_t errcode,int sys_errno,
|
||||
const char *file,int line,const char *comment,...);
|
||||
void ops_print_error(ops_error_t *err);
|
||||
void ops_print_errors(ops_error_t *errstack);
|
||||
void ops_free_errors(ops_error_t *errstack);
|
||||
int ops_has_error(ops_error_t *errstack, ops_errcode_t errcode);
|
||||
|
||||
#define OPS_SYSTEM_ERROR_1(err,code,syscall,fmt,arg) do { ops_push_error(err,OPS_E_SYSTEM_ERROR,errno,__FILE__,__LINE__,syscall); ops_push_error(err,code,0,__FILE__,__LINE__,fmt,arg); } while(0)
|
||||
#define OPS_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); } while(0)
|
||||
#define OPS_ERROR_1(err,code,fmt,arg) do { ops_push_error(err,code,0,__FILE__,__LINE__,fmt,arg); } while(0)
|
||||
#define OPS_ERROR_2(err,code,fmt,arg,arg2) do { ops_push_error(err,code,0,__FILE__,__LINE__,fmt,arg,arg2); } while(0)
|
||||
#define OPS_ERROR_3(err,code,fmt,arg,arg2,arg3) do { ops_push_error(err,code,0,__FILE__,__LINE__,fmt,arg,arg2,arg3); } while(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); } while(0)
|
||||
|
||||
#endif /* OPS_ERRORS */
|
||||
27
openpgpsdk/include/openpgpsdk/final.h
Normal file
27
openpgpsdk/include/openpgpsdk/final.h
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
/*
|
||||
* Copyright (c) 2005-2008 Nominet UK (www.nic.uk)
|
||||
* All rights reserved.
|
||||
* Contributors: Ben Laurie, Rachel Willmer. The Contributors have asserted
|
||||
* their moral rights under the UK Copyright Design and Patents Act 1988 to
|
||||
* be recorded as the authors of this copyright work.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||
* use this file except in compliance with the License.
|
||||
*
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/* A header that is always included last, for things that need to come last */
|
||||
|
||||
#ifdef DMALLOC
|
||||
# include <dmalloc.h>
|
||||
#endif
|
||||
|
||||
29
openpgpsdk/include/openpgpsdk/hash.h
Normal file
29
openpgpsdk/include/openpgpsdk/hash.h
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
/*
|
||||
* Copyright (c) 2005-2008 Nominet UK (www.nic.uk)
|
||||
* All rights reserved.
|
||||
* Contributors: Ben Laurie, Rachel Willmer. The Contributors have asserted
|
||||
* their moral rights under the UK Copyright Design and Patents Act 1988 to
|
||||
* be recorded as the authors of this copyright work.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||
* use this file except in compliance with the License.
|
||||
*
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef __OPS_HASH_H__
|
||||
#define __OPS_HASH_H__
|
||||
#include "openpgpsdk/packet.h"
|
||||
|
||||
void ops_calc_mdc_hash(const unsigned char* preamble, const size_t sz_preamble, const unsigned char* plaintext, const unsigned int sz_plaintext, unsigned char *hashed);
|
||||
ops_boolean_t ops_is_hash_alg_supported(const ops_hash_algorithm_t *hash_alg);
|
||||
|
||||
#endif /*__OPS_HASH_H__*/
|
||||
88
openpgpsdk/include/openpgpsdk/keyring.h
Normal file
88
openpgpsdk/include/openpgpsdk/keyring.h
Normal file
|
|
@ -0,0 +1,88 @@
|
|||
/*
|
||||
* Copyright (c) 2005-2008 Nominet UK (www.nic.uk)
|
||||
* All rights reserved.
|
||||
* Contributors: Ben Laurie, Rachel Willmer. The Contributors have asserted
|
||||
* their moral rights under the UK Copyright Design and Patents Act 1988 to
|
||||
* be recorded as the authors of this copyright work.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||
* use this file except in compliance with the License.
|
||||
*
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
*/
|
||||
|
||||
#ifndef OPS_KEYRING_H
|
||||
#define OPS_KEYRING_H
|
||||
|
||||
#include "packet.h"
|
||||
#include "memory.h"
|
||||
|
||||
typedef struct ops_keydata ops_keydata_t;
|
||||
|
||||
/** \struct ops_keyring_t
|
||||
* A keyring
|
||||
*/
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int nkeys; // while we are constructing a key, this is the offset
|
||||
int nkeys_allocated;
|
||||
ops_keydata_t *keys;
|
||||
} ops_keyring_t;
|
||||
|
||||
const ops_keydata_t *
|
||||
ops_keyring_find_key_by_id(const ops_keyring_t *keyring,
|
||||
const unsigned char keyid[OPS_KEY_ID_SIZE]);
|
||||
const ops_keydata_t *
|
||||
ops_keyring_find_key_by_userid(const ops_keyring_t *keyring,
|
||||
const char* userid);
|
||||
void ops_keydata_free(ops_keydata_t *key);
|
||||
void ops_keyring_free(ops_keyring_t *keyring);
|
||||
void ops_dump_keyring(const ops_keyring_t *keyring);
|
||||
const ops_public_key_t *
|
||||
ops_get_public_key_from_data(const ops_keydata_t *data);
|
||||
ops_boolean_t ops_is_key_secret(const ops_keydata_t *data);
|
||||
const ops_secret_key_t *
|
||||
ops_get_secret_key_from_data(const ops_keydata_t *data);
|
||||
ops_secret_key_t *
|
||||
ops_get_writable_secret_key_from_data(ops_keydata_t *data);
|
||||
ops_secret_key_t *ops_decrypt_secret_key_from_data(const ops_keydata_t *key,
|
||||
const char *pphrase);
|
||||
|
||||
ops_boolean_t ops_keyring_read_from_file(ops_keyring_t *keyring, const ops_boolean_t armour, const char *filename);
|
||||
ops_boolean_t ops_keyring_read_from_mem(ops_keyring_t *keyring, const ops_boolean_t armour, ops_memory_t *mem);
|
||||
|
||||
char *ops_malloc_passphrase(char *passphrase);
|
||||
char *ops_get_passphrase(void);
|
||||
|
||||
void ops_keyring_list(const ops_keyring_t* keyring);
|
||||
|
||||
void ops_set_secret_key(ops_parser_content_union_t* content,const ops_keydata_t *key);
|
||||
|
||||
const unsigned char* ops_get_key_id(const ops_keydata_t *key);
|
||||
unsigned ops_get_user_id_count(const ops_keydata_t *key);
|
||||
const unsigned char* ops_get_user_id(const ops_keydata_t *key, unsigned index);
|
||||
ops_boolean_t ops_is_key_supported(const ops_keydata_t *key);
|
||||
const ops_keydata_t* ops_keyring_get_key_by_index(const ops_keyring_t *keyring, int index);
|
||||
|
||||
ops_user_id_t* ops_add_userid_to_keydata(ops_keydata_t* keydata, const ops_user_id_t* userid);
|
||||
ops_packet_t* ops_add_packet_to_keydata(ops_keydata_t* keydata, const ops_packet_t* packet);
|
||||
void ops_add_signed_userid_to_keydata(ops_keydata_t* keydata, const ops_user_id_t* userid, const ops_packet_t* packet);
|
||||
|
||||
ops_boolean_t ops_add_selfsigned_userid_to_keydata(ops_keydata_t* keydata, ops_user_id_t* userid);
|
||||
|
||||
ops_keydata_t *ops_keydata_new(void);
|
||||
void ops_keydata_init(ops_keydata_t* keydata, const ops_content_tag_t type);
|
||||
|
||||
#endif
|
||||
40
openpgpsdk/include/openpgpsdk/lists.h
Normal file
40
openpgpsdk/include/openpgpsdk/lists.h
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
/*
|
||||
* Copyright (c) 2005-2008 Nominet UK (www.nic.uk)
|
||||
* All rights reserved.
|
||||
* Contributors: Ben Laurie, Rachel Willmer. The Contributors have asserted
|
||||
* their moral rights under the UK Copyright Design and Patents Act 1988 to
|
||||
* be recorded as the authors of this copyright work.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||
* use this file except in compliance with the License.
|
||||
*
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
*/
|
||||
|
||||
#ifndef OPS_LISTS_H
|
||||
#define OPS_LISTS_H
|
||||
|
||||
/** ops_ulong_list_t */
|
||||
typedef struct
|
||||
{
|
||||
unsigned int size;/* num of array slots allocated */
|
||||
unsigned int used; /* num of array slots currently used */
|
||||
unsigned long *ulongs;
|
||||
} ops_ulong_list_t;
|
||||
|
||||
void ops_ulong_list_init(ops_ulong_list_t *list);
|
||||
void ops_ulong_list_free(ops_ulong_list_t *list);
|
||||
unsigned int ops_ulong_list_add(ops_ulong_list_t *list, unsigned long *ulong);
|
||||
|
||||
#endif /* OPS_LISTS_H */
|
||||
52
openpgpsdk/include/openpgpsdk/memory.h
Normal file
52
openpgpsdk/include/openpgpsdk/memory.h
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
/*
|
||||
* Copyright (c) 2005-2008 Nominet UK (www.nic.uk)
|
||||
* All rights reserved.
|
||||
* Contributors: Ben Laurie, Rachel Willmer. The Contributors have asserted
|
||||
* their moral rights under the UK Copyright Design and Patents Act 1988 to
|
||||
* be recorded as the authors of this copyright work.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||
* use this file except in compliance with the License.
|
||||
*
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <openssl/bn.h>
|
||||
#include "packet.h"
|
||||
|
||||
#ifndef OPS_MEMORY_H
|
||||
#define OPS_MEMORY_H
|
||||
|
||||
/** ops_memory_t
|
||||
*/
|
||||
typedef struct ops_memory ops_memory_t;
|
||||
|
||||
ops_memory_t *ops_memory_new(void);
|
||||
void ops_memory_free(ops_memory_t *mem);
|
||||
void ops_memory_init(ops_memory_t *mem,size_t initial_size);
|
||||
void ops_memory_pad(ops_memory_t *mem,size_t length);
|
||||
void ops_memory_add(ops_memory_t *mem,const unsigned char *src,size_t length);
|
||||
void ops_memory_place_int(ops_memory_t *mem,unsigned offset,unsigned n,
|
||||
size_t length);
|
||||
void ops_memory_make_packet(ops_memory_t *out,ops_content_tag_t tag);
|
||||
void ops_memory_clear(ops_memory_t *mem);
|
||||
void ops_memory_release(ops_memory_t *mem);
|
||||
|
||||
void ops_writer_set_memory(ops_create_info_t *info,ops_memory_t *mem);
|
||||
|
||||
size_t ops_memory_get_length(const ops_memory_t *mem);
|
||||
void *ops_memory_get_data(ops_memory_t *mem);
|
||||
|
||||
#endif
|
||||
170
openpgpsdk/include/openpgpsdk/packet-parse.h
Normal file
170
openpgpsdk/include/openpgpsdk/packet-parse.h
Normal file
|
|
@ -0,0 +1,170 @@
|
|||
/*
|
||||
* Copyright (c) 2005-2008 Nominet UK (www.nic.uk)
|
||||
* All rights reserved.
|
||||
* Contributors: Ben Laurie, Rachel Willmer. The Contributors have asserted
|
||||
* their moral rights under the UK Copyright Design and Patents Act 1988 to
|
||||
* be recorded as the authors of this copyright work.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||
* use this file except in compliance with the License.
|
||||
*
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
* Parser for OpenPGP packets - headers.
|
||||
*/
|
||||
|
||||
#ifndef OPS_PACKET_PARSE_H
|
||||
#define OPS_PACKET_PARSE_H
|
||||
|
||||
#include "types.h"
|
||||
#include "packet.h"
|
||||
#include "lists.h"
|
||||
|
||||
/** ops_region_t */
|
||||
typedef struct ops_region
|
||||
{
|
||||
struct ops_region *parent;
|
||||
unsigned length;
|
||||
unsigned length_read;
|
||||
unsigned last_read; /*!< length of last read, only valid in deepest child */
|
||||
ops_boolean_t indeterminate:1;
|
||||
} ops_region_t;
|
||||
|
||||
void ops_init_subregion(ops_region_t *subregion,ops_region_t *region);
|
||||
|
||||
#if 0
|
||||
/** Return values for reader functions e.g. ops_packet_reader_t() */
|
||||
enum ops_reader_ret_t
|
||||
{
|
||||
OPS_R_OK =0, /*!< success */
|
||||
OPS_R_EOF =1, /*!< reached end of file, no data has been returned */
|
||||
OPS_R_EARLY_EOF =2, /*!< could not read the requested
|
||||
number of bytes and either
|
||||
OPS_RETURN_LENGTH was not set and at
|
||||
least 1 byte was read, or there was
|
||||
an abnormal end to the file (or
|
||||
armoured block) */
|
||||
OPS_R_PARTIAL_READ =3, /*!< if OPS_RETURN_LENGTH is set and
|
||||
the buffer was not filled */
|
||||
OPS_R_ERROR =4, /*!< if there was an error reading */
|
||||
};
|
||||
#endif
|
||||
|
||||
/** ops_parse_callback_return_t */
|
||||
typedef enum
|
||||
{
|
||||
OPS_RELEASE_MEMORY,
|
||||
OPS_KEEP_MEMORY,
|
||||
OPS_FINISHED
|
||||
} ops_parse_cb_return_t;
|
||||
|
||||
typedef struct ops_parse_cb_info ops_parse_cb_info_t;
|
||||
|
||||
typedef ops_parse_cb_return_t
|
||||
ops_parse_cb_t(const ops_parser_content_t *content,
|
||||
ops_parse_cb_info_t *cbinfo);
|
||||
|
||||
typedef struct ops_parse_info ops_parse_info_t;
|
||||
typedef struct ops_reader_info ops_reader_info_t;
|
||||
typedef struct ops_crypt_info ops_crypt_info_t;
|
||||
|
||||
/*
|
||||
A reader MUST read at least one byte if it can, and should read up
|
||||
to the number asked for. Whether it reads more for efficiency is
|
||||
its own decision, but if it is a stacked reader it should never
|
||||
read more than the length of the region it operates in (which it
|
||||
would have to be given when it is stacked).
|
||||
|
||||
If a read is short because of EOF, then it should return the short
|
||||
read (obviously this will be zero on the second attempt, if not the
|
||||
first). Because a reader is not obliged to do a full read, only a
|
||||
zero return can be taken as an indication of EOF.
|
||||
|
||||
If there is an error, then the callback should be notified, the
|
||||
error stacked, and -1 should be returned.
|
||||
|
||||
Note that although length is a size_t, a reader will never be asked
|
||||
to read more than INT_MAX in one go.
|
||||
|
||||
*/
|
||||
|
||||
typedef int ops_reader_t(void *dest,size_t length,ops_error_t **errors,
|
||||
ops_reader_info_t *rinfo,ops_parse_cb_info_t *cbinfo);
|
||||
|
||||
typedef void ops_reader_destroyer_t(ops_reader_info_t *rinfo);
|
||||
|
||||
ops_parse_info_t *ops_parse_info_new(void);
|
||||
void ops_parse_info_delete(ops_parse_info_t *pinfo);
|
||||
ops_error_t *ops_parse_info_get_errors(ops_parse_info_t *pinfo);
|
||||
ops_crypt_t *ops_parse_get_decrypt(ops_parse_info_t *pinfo);
|
||||
|
||||
void ops_parse_cb_set(ops_parse_info_t *pinfo,ops_parse_cb_t *cb,void *arg);
|
||||
void ops_parse_cb_push(ops_parse_info_t *pinfo,ops_parse_cb_t *cb,void *arg);
|
||||
void *ops_parse_cb_get_arg(ops_parse_cb_info_t *cbinfo);
|
||||
void *ops_parse_cb_get_errors(ops_parse_cb_info_t *cbinfo);
|
||||
void ops_reader_set(ops_parse_info_t *pinfo,ops_reader_t *reader,ops_reader_destroyer_t *destroyer,void *arg);
|
||||
void ops_reader_push(ops_parse_info_t *pinfo,ops_reader_t *reader,ops_reader_destroyer_t *destroyer,void *arg);
|
||||
void ops_reader_pop(ops_parse_info_t *pinfo);
|
||||
void *ops_reader_get_arg_from_pinfo(ops_parse_info_t *pinfo);
|
||||
|
||||
void *ops_reader_get_arg(ops_reader_info_t *rinfo);
|
||||
|
||||
ops_parse_cb_return_t ops_parse_cb(const ops_parser_content_t *content,
|
||||
ops_parse_cb_info_t *cbinfo);
|
||||
ops_parse_cb_return_t ops_parse_stacked_cb(const ops_parser_content_t *content,
|
||||
ops_parse_cb_info_t *cbinfo);
|
||||
ops_reader_info_t *ops_parse_get_rinfo(ops_parse_info_t *pinfo);
|
||||
|
||||
int ops_parse(ops_parse_info_t *parse_info);
|
||||
int ops_parse_and_print_errors(ops_parse_info_t *parse_info);
|
||||
int ops_parse_and_save_errs(ops_parse_info_t *parse_info,ops_ulong_list_t *errs);
|
||||
int ops_parse_errs(ops_parse_info_t *parse_info,ops_ulong_list_t *errs);
|
||||
|
||||
void ops_parse_and_validate(ops_parse_info_t *parse_info);
|
||||
|
||||
/** Used to specify whether subpackets should be returned raw, parsed or ignored.
|
||||
*/
|
||||
enum ops_parse_type_t
|
||||
{
|
||||
OPS_PARSE_RAW, /*!< Callback Raw */
|
||||
OPS_PARSE_PARSED, /*!< Callback Parsed */
|
||||
OPS_PARSE_IGNORE, /*!< Don't callback */
|
||||
};
|
||||
|
||||
void ops_parse_options(ops_parse_info_t *pinfo,ops_content_tag_t tag,
|
||||
ops_parse_type_t type);
|
||||
|
||||
ops_boolean_t ops_limited_read(unsigned char *dest,size_t length,
|
||||
ops_region_t *region,ops_error_t **errors,
|
||||
ops_reader_info_t *rinfo,
|
||||
ops_parse_cb_info_t *cbinfo);
|
||||
ops_boolean_t ops_stacked_limited_read(unsigned char *dest,unsigned length,
|
||||
ops_region_t *region,
|
||||
ops_error_t **errors,
|
||||
ops_reader_info_t *rinfo,
|
||||
ops_parse_cb_info_t *cbinfo);
|
||||
void ops_parse_hash_init(ops_parse_info_t *pinfo,ops_hash_algorithm_t type,
|
||||
const unsigned char *keyid);
|
||||
void ops_parse_hash_data(ops_parse_info_t *pinfo,const void *data,
|
||||
size_t length);
|
||||
void ops_parse_hash_finish(ops_parse_info_t *pinfo);
|
||||
ops_hash_t *ops_parse_hash_find(ops_parse_info_t *pinfo,
|
||||
const unsigned char keyid[OPS_KEY_ID_SIZE]);
|
||||
|
||||
ops_reader_t ops_stacked_read;
|
||||
|
||||
/* vim:set textwidth=120: */
|
||||
/* vim:set ts=8: */
|
||||
|
||||
|
||||
#endif
|
||||
38
openpgpsdk/include/openpgpsdk/packet-show-cast.h
Normal file
38
openpgpsdk/include/openpgpsdk/packet-show-cast.h
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
/* Generated from packet-show.cast by ../../util/caster.pl, do not edit. */
|
||||
|
||||
#include "types.h"
|
||||
|
||||
/* (line 4) char *show_packet_tag(ops_packet_tag_t packet_tag, packet_tag_map_t *packet_tag_map) -> char *ops_str_from_map(int packet_tag, ops_map_t *packet_tag_map) */
|
||||
char *ops_str_from_map(int packet_tag, ops_map_t *packet_tag_map);
|
||||
#define show_packet_tag(packet_tag,packet_tag_map) ops_str_from_map(CHECKED_INSTANCE_OF(ops_packet_tag_t , packet_tag),CHECKED_INSTANCE_OF( packet_tag_map_t *, packet_tag_map))
|
||||
typedef char * show_packet_tag_t(ops_packet_tag_t , packet_tag_map_t *);
|
||||
|
||||
/* (line 5) char *show_sig_type(ops_sig_type_t sig_type, sig_type_map_t *sig_type_map) -> char *ops_str_from_map(int sig_type, ops_map_t *sig_type_map) */
|
||||
char *ops_str_from_map(int sig_type, ops_map_t *sig_type_map);
|
||||
#define show_sig_type(sig_type,sig_type_map) ops_str_from_map(CHECKED_INSTANCE_OF(ops_sig_type_t , sig_type),CHECKED_INSTANCE_OF( sig_type_map_t *, sig_type_map))
|
||||
typedef char * show_sig_type_t(ops_sig_type_t , sig_type_map_t *);
|
||||
|
||||
/* (line 6) char *show_pka(ops_public_key_algorithm_t pka, public_key_algorithm_map_t *pka_map) -> char *ops_str_from_map(int pka, ops_map_t *pka_map) */
|
||||
char *ops_str_from_map(int pka, ops_map_t *pka_map);
|
||||
#define show_pka(pka,pka_map) ops_str_from_map(CHECKED_INSTANCE_OF(ops_public_key_algorithm_t , pka),CHECKED_INSTANCE_OF( public_key_algorithm_map_t *, pka_map))
|
||||
typedef char * show_pka_t(ops_public_key_algorithm_t , public_key_algorithm_map_t *);
|
||||
|
||||
/* (line 7) char *show_ss_type(ops_ss_type_t ss_type, ss_type_map_t *ss_type_map) -> char *ops_str_from_map(int ss_type, ops_map_t *ss_type_map) */
|
||||
char *ops_str_from_map(int ss_type, ops_map_t *ss_type_map);
|
||||
#define show_ss_type(ss_type,ss_type_map) ops_str_from_map(CHECKED_INSTANCE_OF(ops_ss_type_t , ss_type),CHECKED_INSTANCE_OF( ss_type_map_t *, ss_type_map))
|
||||
typedef char * show_ss_type_t(ops_ss_type_t , ss_type_map_t *);
|
||||
|
||||
/* (line 8) char *show_ss_rr_code(ops_ss_rr_code_t ss_rr_code, ss_rr_code_map_t *ss_rr_code_map) -> char *ops_str_from_map(int ss_rr_code, ops_map_t *ss_rr_code_map) */
|
||||
char *ops_str_from_map(int ss_rr_code, ops_map_t *ss_rr_code_map);
|
||||
#define show_ss_rr_code(ss_rr_code,ss_rr_code_map) ops_str_from_map(CHECKED_INSTANCE_OF(ops_ss_rr_code_t , ss_rr_code),CHECKED_INSTANCE_OF( ss_rr_code_map_t *, ss_rr_code_map))
|
||||
typedef char * show_ss_rr_code_t(ops_ss_rr_code_t , ss_rr_code_map_t *);
|
||||
|
||||
/* (line 9) char *show_hash_algorithm(unsigned char hash,+ops_map_t *hash_algorithm_map) -> char *ops_str_from_map(int hash,ops_map_t *hash_algorithm_map) */
|
||||
char *ops_str_from_map(int hash,ops_map_t *hash_algorithm_map);
|
||||
#define show_hash_algorithm(hash) ops_str_from_map(CHECKED_INSTANCE_OF(unsigned char , hash),CHECKED_INSTANCE_OF(ops_map_t *, hash_algorithm_map))
|
||||
typedef char * show_hash_algorithm_t(unsigned char );
|
||||
|
||||
/* (line 10) char *show_symmetric_algorithm(unsigned char hash,+ops_map_t *symmetric_algorithm_map) -> char *ops_str_from_map(int hash,ops_map_t *symmetric_algorithm_map) */
|
||||
char *ops_str_from_map(int hash,ops_map_t *symmetric_algorithm_map);
|
||||
#define show_symmetric_algorithm(hash) ops_str_from_map(CHECKED_INSTANCE_OF(unsigned char , hash),CHECKED_INSTANCE_OF(ops_map_t *, symmetric_algorithm_map))
|
||||
typedef char * show_symmetric_algorithm_t(unsigned char );
|
||||
94
openpgpsdk/include/openpgpsdk/packet-show.h
Normal file
94
openpgpsdk/include/openpgpsdk/packet-show.h
Normal file
|
|
@ -0,0 +1,94 @@
|
|||
/*
|
||||
* Copyright (c) 2005-2008 Nominet UK (www.nic.uk)
|
||||
* All rights reserved.
|
||||
* Contributors: Ben Laurie, Rachel Willmer. The Contributors have asserted
|
||||
* their moral rights under the UK Copyright Design and Patents Act 1988 to
|
||||
* be recorded as the authors of this copyright work.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||
* use this file except in compliance with the License.
|
||||
*
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
*/
|
||||
|
||||
#ifndef OPS_PACKET_TO_TEXT_H
|
||||
#define OPS_PACKET_TO_TEXT_H
|
||||
|
||||
#ifndef OPS_PACKET_H
|
||||
#include "packet.h"
|
||||
#endif
|
||||
|
||||
/** ops_list_t
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
unsigned int size;/* num of array slots allocated */
|
||||
unsigned int used; /* num of array slots currently used */
|
||||
char **strings;
|
||||
} ops_list_t;
|
||||
|
||||
/** ops_text_t
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
ops_list_t known;
|
||||
ops_list_t unknown;
|
||||
} ops_text_t;
|
||||
|
||||
/** ops_bit_map_t
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
unsigned char mask;
|
||||
char *string;
|
||||
} ops_bit_map_t;
|
||||
|
||||
void ops_text_init(ops_text_t *text);
|
||||
void ops_text_free(ops_text_t *text);
|
||||
|
||||
const char *ops_show_packet_tag(ops_packet_tag_t packet_tag);
|
||||
const char *ops_show_ss_type(ops_ss_type_t ss_type);
|
||||
|
||||
const char *ops_show_sig_type(ops_sig_type_t sig_type);
|
||||
const char *ops_show_pka(ops_public_key_algorithm_t pka);
|
||||
|
||||
ops_text_t *ops_showall_ss_preferred_compression(ops_ss_preferred_compression_t ss_preferred_compression);
|
||||
const char *ops_show_ss_preferred_compression(unsigned char octet);
|
||||
|
||||
ops_text_t *ops_showall_ss_preferred_hash(ops_ss_preferred_hash_t ss_preferred_hash);
|
||||
const char *ops_show_hash_algorithm(unsigned char octet);
|
||||
const char *ops_show_symmetric_algorithm(unsigned char hash);
|
||||
|
||||
ops_text_t *ops_showall_ss_preferred_ska(ops_ss_preferred_ska_t ss_preferred_ska);
|
||||
const char *ops_show_ss_preferred_ska(unsigned char octet);
|
||||
|
||||
const char *ops_show_ss_rr_code(ops_ss_rr_code_t ss_rr_code);
|
||||
|
||||
ops_text_t *ops_showall_ss_features(ops_ss_features_t ss_features);
|
||||
|
||||
ops_text_t *ops_showall_ss_key_flags(ops_ss_key_flags_t ss_key_flags);
|
||||
const char *ops_show_ss_key_flag(unsigned char octet, ops_bit_map_t *map);
|
||||
|
||||
ops_text_t *ops_showall_ss_key_server_prefs(ops_ss_key_server_prefs_t ss_key_server_prefs);
|
||||
const char *ops_show_ss_key_server_prefs(unsigned char octet,
|
||||
ops_bit_map_t *map);
|
||||
|
||||
ops_text_t *ops_showall_ss_notation_data_flags(ops_ss_notation_data_t ss_notation_data);
|
||||
|
||||
char *ops_str_from_map(int code, ops_map_t *map);
|
||||
|
||||
/* vim:set textwidth=120: */
|
||||
/* vim:set ts=8: */
|
||||
|
||||
#endif /* OPS_PACKET_TO_TEXT_H */
|
||||
1053
openpgpsdk/include/openpgpsdk/packet.h
Normal file
1053
openpgpsdk/include/openpgpsdk/packet.h
Normal file
File diff suppressed because it is too large
Load diff
28
openpgpsdk/include/openpgpsdk/random.h
Normal file
28
openpgpsdk/include/openpgpsdk/random.h
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
/*
|
||||
* Copyright (c) 2005-2008 Nominet UK (www.nic.uk)
|
||||
* All rights reserved.
|
||||
* Contributors: Ben Laurie, Rachel Willmer. The Contributors have asserted
|
||||
* their moral rights under the UK Copyright Design and Patents Act 1988 to
|
||||
* be recorded as the authors of this copyright work.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||
* use this file except in compliance with the License.
|
||||
*
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifdef WIN32
|
||||
#include <malloc.h>
|
||||
#else
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
void ops_random(void *dest,size_t length);
|
||||
93
openpgpsdk/include/openpgpsdk/readerwriter.h
Normal file
93
openpgpsdk/include/openpgpsdk/readerwriter.h
Normal file
|
|
@ -0,0 +1,93 @@
|
|||
/*
|
||||
* Copyright (c) 2005-2008 Nominet UK (www.nic.uk)
|
||||
* All rights reserved.
|
||||
* Contributors: Ben Laurie, Rachel Willmer. The Contributors have asserted
|
||||
* their moral rights under the UK Copyright Design and Patents Act 1988 to
|
||||
* be recorded as the authors of this copyright work.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||
* use this file except in compliance with the License.
|
||||
*
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef __OPS_READERWRITER_H__
|
||||
#define __OPS_READERWRITER_H__
|
||||
|
||||
#include <openpgpsdk/memory.h>
|
||||
#include <openpgpsdk/create.h>
|
||||
|
||||
|
||||
void ops_reader_set_fd(ops_parse_info_t *pinfo,int fd);
|
||||
void ops_reader_set_memory(ops_parse_info_t *pinfo,const void *buffer,
|
||||
size_t length);
|
||||
|
||||
// Do a sum mod 65536 of all bytes read (as needed for secret keys)
|
||||
void ops_reader_push_sum16(ops_parse_info_t *pinfo);
|
||||
unsigned short ops_reader_pop_sum16(ops_parse_info_t *pinfo);
|
||||
|
||||
void ops_reader_push_se_ip_data(ops_parse_info_t *pinfo, ops_crypt_t *decrypt,
|
||||
ops_region_t *region);
|
||||
void ops_reader_pop_se_ip_data(ops_parse_info_t* pinfo);
|
||||
|
||||
//
|
||||
ops_boolean_t ops_write_mdc(const unsigned char *hashed,
|
||||
ops_create_info_t* info);
|
||||
ops_boolean_t ops_write_se_ip_pktset(const unsigned char *data,
|
||||
const unsigned int len,
|
||||
ops_crypt_t *crypt,
|
||||
ops_create_info_t *info);
|
||||
void ops_writer_push_encrypt_crypt(ops_create_info_t *cinfo,
|
||||
ops_crypt_t *crypt);
|
||||
void ops_writer_push_encrypt_se_ip(ops_create_info_t *cinfo,
|
||||
const ops_keydata_t *pub_key);
|
||||
// Secret Key checksum
|
||||
|
||||
void ops_push_skey_checksum_writer(ops_create_info_t *cinfo, ops_secret_key_t *skey);
|
||||
ops_boolean_t ops_pop_skey_checksum_writer(ops_create_info_t *cinfo);
|
||||
|
||||
|
||||
// memory writing
|
||||
void ops_setup_memory_write(ops_create_info_t **cinfo, ops_memory_t **mem, size_t bufsz);
|
||||
void ops_teardown_memory_write(ops_create_info_t *cinfo, ops_memory_t *mem);
|
||||
|
||||
// memory reading
|
||||
void ops_setup_memory_read(ops_parse_info_t **pinfo, ops_memory_t *mem,
|
||||
void* arg,
|
||||
ops_parse_cb_return_t callback(const ops_parser_content_t *, ops_parse_cb_info_t *),ops_boolean_t accumulate);
|
||||
void ops_teardown_memory_read(ops_parse_info_t *pinfo, ops_memory_t *mem);
|
||||
|
||||
// file writing
|
||||
int ops_setup_file_write(ops_create_info_t **cinfo, const char* filename, ops_boolean_t allow_overwrite);
|
||||
void ops_teardown_file_write(ops_create_info_t *cinfo, int fd);
|
||||
|
||||
// file appending
|
||||
int ops_setup_file_append(ops_create_info_t **cinfo, const char* filename);
|
||||
void ops_teardown_file_append(ops_create_info_t *cinfo, int fd);
|
||||
|
||||
// file reading
|
||||
int ops_setup_file_read(ops_parse_info_t **pinfo, const char *filename, void* arg,
|
||||
ops_parse_cb_return_t callback(const ops_parser_content_t *, ops_parse_cb_info_t *), ops_boolean_t accumulate);
|
||||
void ops_teardown_file_read(ops_parse_info_t *pinfo, int fd);
|
||||
|
||||
ops_boolean_t ops_reader_set_accumulate(ops_parse_info_t* pinfo, ops_boolean_t state);
|
||||
|
||||
// useful callbacks
|
||||
ops_parse_cb_return_t
|
||||
callback_literal_data(const ops_parser_content_t *content_,ops_parse_cb_info_t *cbinfo);
|
||||
ops_parse_cb_return_t
|
||||
callback_pk_session_key(const ops_parser_content_t *content_,ops_parse_cb_info_t *cbinfo);
|
||||
ops_parse_cb_return_t
|
||||
callback_cmd_get_secret_key(const ops_parser_content_t *content_,ops_parse_cb_info_t *cbinfo);
|
||||
ops_parse_cb_return_t
|
||||
callback_cmd_get_passphrase_from_cmdline(const ops_parser_content_t *content_,ops_parse_cb_info_t *cbinfo);
|
||||
|
||||
#endif /*OPS_READERWRITER_H__*/
|
||||
95
openpgpsdk/include/openpgpsdk/signature.h
Normal file
95
openpgpsdk/include/openpgpsdk/signature.h
Normal file
|
|
@ -0,0 +1,95 @@
|
|||
/*
|
||||
* Copyright (c) 2005-2008 Nominet UK (www.nic.uk)
|
||||
* All rights reserved.
|
||||
* Contributors: Ben Laurie, Rachel Willmer. The Contributors have asserted
|
||||
* their moral rights under the UK Copyright Design and Patents Act 1988 to
|
||||
* be recorded as the authors of this copyright work.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||
* use this file except in compliance with the License.
|
||||
*
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
*/
|
||||
|
||||
#ifndef OPS_SIGNATURE_H
|
||||
#define OPS_SIGNATURE_H
|
||||
|
||||
#include "packet.h"
|
||||
#include "util.h"
|
||||
#include "create.h"
|
||||
|
||||
typedef struct ops_create_signature ops_create_signature_t;
|
||||
|
||||
ops_create_signature_t *ops_create_signature_new(void);
|
||||
void ops_create_signature_delete(ops_create_signature_t *sig);
|
||||
|
||||
ops_boolean_t
|
||||
ops_check_user_id_certification_signature(const ops_public_key_t *key,
|
||||
const ops_user_id_t *id,
|
||||
const ops_signature_t *sig,
|
||||
const ops_public_key_t *signer,
|
||||
const unsigned char *raw_packet);
|
||||
ops_boolean_t
|
||||
ops_check_user_attribute_certification_signature(const ops_public_key_t *key,
|
||||
const ops_user_attribute_t *attribute,
|
||||
const ops_signature_t *sig,
|
||||
const ops_public_key_t *signer,
|
||||
const unsigned char *raw_packet);
|
||||
ops_boolean_t
|
||||
ops_check_subkey_signature(const ops_public_key_t *key,
|
||||
const ops_public_key_t *subkey,
|
||||
const ops_signature_t *sig,
|
||||
const ops_public_key_t *signer,
|
||||
const unsigned char *raw_packet);
|
||||
ops_boolean_t
|
||||
ops_check_direct_signature(const ops_public_key_t *key,
|
||||
const ops_signature_t *sig,
|
||||
const ops_public_key_t *signer,
|
||||
const unsigned char *raw_packet);
|
||||
ops_boolean_t
|
||||
ops_check_hash_signature(ops_hash_t *hash,
|
||||
const ops_signature_t *sig,
|
||||
const ops_public_key_t *signer);
|
||||
void ops_signature_start_key_signature(ops_create_signature_t *sig,
|
||||
const ops_public_key_t *key,
|
||||
const ops_user_id_t *id,
|
||||
ops_sig_type_t type);
|
||||
void ops_signature_start_cleartext_signature(ops_create_signature_t *sig,
|
||||
const ops_secret_key_t *key,
|
||||
const ops_hash_algorithm_t hash,
|
||||
const ops_sig_type_t type);
|
||||
void ops_signature_start_message_signature(ops_create_signature_t *sig,
|
||||
const ops_secret_key_t *key,
|
||||
const ops_hash_algorithm_t hash,
|
||||
const ops_sig_type_t type);
|
||||
|
||||
void ops_signature_add_data(ops_create_signature_t *sig,const void *buf,
|
||||
size_t length);
|
||||
ops_hash_t *ops_signature_get_hash(ops_create_signature_t *sig);
|
||||
ops_boolean_t ops_signature_hashed_subpackets_end(ops_create_signature_t *sig);
|
||||
ops_boolean_t ops_write_signature(ops_create_signature_t *sig,const ops_public_key_t *key,
|
||||
const ops_secret_key_t *skey, ops_create_info_t *opt);
|
||||
ops_boolean_t ops_signature_add_creation_time(ops_create_signature_t *sig,time_t when);
|
||||
ops_boolean_t ops_signature_add_issuer_key_id(ops_create_signature_t *sig,
|
||||
const unsigned char keyid[OPS_KEY_ID_SIZE]);
|
||||
void ops_signature_add_primary_user_id(ops_create_signature_t *sig,
|
||||
ops_boolean_t primary);
|
||||
|
||||
// Standard Interface
|
||||
ops_boolean_t ops_sign_file_as_cleartext(const char* input_filename, const char* output_filename, const ops_secret_key_t *skey, const ops_boolean_t overwrite);
|
||||
ops_boolean_t ops_sign_buf_as_cleartext(const char* input, const size_t len, ops_memory_t** output, const ops_secret_key_t *skey);
|
||||
ops_boolean_t ops_sign_file(const char* input_filename, const char* output_filename, const ops_secret_key_t *skey, const ops_boolean_t use_armour, const ops_boolean_t overwrite);
|
||||
ops_memory_t * ops_sign_buf(const void* input, const size_t input_len, const ops_sig_type_t sig_type, const ops_secret_key_t *skey, const ops_boolean_t use_armour);
|
||||
|
||||
#endif
|
||||
47
openpgpsdk/include/openpgpsdk/std_print.h
Normal file
47
openpgpsdk/include/openpgpsdk/std_print.h
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
/*
|
||||
* Copyright (c) 2005-2008 Nominet UK (www.nic.uk)
|
||||
* All rights reserved.
|
||||
* Contributors: Ben Laurie, Rachel Willmer. The Contributors have asserted
|
||||
* their moral rights under the UK Copyright Design and Patents Act 1988 to
|
||||
* be recorded as the authors of this copyright work.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||
* use this file except in compliance with the License.
|
||||
*
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
*/
|
||||
|
||||
#ifndef OPS_STD_PRINT_H
|
||||
#define OPS_STD_PRINT_H
|
||||
|
||||
#include "openpgpsdk/packet.h"
|
||||
#include "openpgpsdk/packet-parse.h"
|
||||
#include "openpgpsdk/keyring.h"
|
||||
|
||||
void print_bn( const char *name,
|
||||
const BIGNUM *bn);
|
||||
void ops_print_pk_session_key(ops_content_tag_t tag,
|
||||
const ops_pk_session_key_t *key);
|
||||
void ops_print_public_keydata(const ops_keydata_t *key);
|
||||
|
||||
void ops_print_public_keydata_verbose(const ops_keydata_t *key);
|
||||
void ops_print_public_key(const ops_public_key_t *pkey);
|
||||
|
||||
void ops_print_secret_keydata(const ops_keydata_t *key);
|
||||
void ops_print_secret_keydata_verbose(const ops_keydata_t *key);
|
||||
//void ops_print_secret_key(const ops_content_tag_t type, const ops_secret_key_t* skey);
|
||||
int ops_print_packet(const ops_parser_content_t *content_);
|
||||
void ops_list_packets(char *filename, ops_boolean_t armour, ops_keyring_t* pubring, ops_parse_cb_t* cb_get_passphrase);
|
||||
|
||||
#endif
|
||||
30
openpgpsdk/include/openpgpsdk/streamwriter.h
Normal file
30
openpgpsdk/include/openpgpsdk/streamwriter.h
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
/*
|
||||
* Copyright (c) 2005-2008 Nominet UK (www.nic.uk)
|
||||
* All rights reserved.
|
||||
* Contributors: Ben Laurie, Rachel Willmer. The Contributors have asserted
|
||||
* their moral rights under the UK Copyright Design and Patents Act 1988 to
|
||||
* be recorded as the authors of this copyright work.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||
* use this file except in compliance with the License.
|
||||
*
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef __OPS_STREAMWRITER_H__
|
||||
#define __OPS_STREAMWRITER_H__
|
||||
|
||||
#include <openpgpsdk/readerwriter.h>
|
||||
|
||||
void ops_writer_push_stream_encrypt_se_ip(ops_create_info_t *cinfo,
|
||||
const ops_key_data_t *pub_key);
|
||||
|
||||
#endif /*__OPS_STREAMWRITER_H__*/
|
||||
96
openpgpsdk/include/openpgpsdk/types.h
Normal file
96
openpgpsdk/include/openpgpsdk/types.h
Normal file
|
|
@ -0,0 +1,96 @@
|
|||
/*
|
||||
* Copyright (c) 2005-2008 Nominet UK (www.nic.uk)
|
||||
* All rights reserved.
|
||||
* Contributors: Ben Laurie, Rachel Willmer. The Contributors have asserted
|
||||
* their moral rights under the UK Copyright Design and Patents Act 1988 to
|
||||
* be recorded as the authors of this copyright work.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||
* use this file except in compliance with the License.
|
||||
*
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
*/
|
||||
|
||||
#ifndef OPS_TYPES_H
|
||||
#define OPS_TYPES_H
|
||||
|
||||
/** Special type for intermediate function casting, avoids warnings on
|
||||
some platforms
|
||||
*/
|
||||
typedef void (*ops_void_fptr)(void);
|
||||
#define ops_fcast(f) ((ops_void_fptr)f)
|
||||
|
||||
/** ops_map_t
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
int type;
|
||||
char *string;
|
||||
} ops_map_t;
|
||||
|
||||
/** Boolean type */
|
||||
typedef unsigned ops_boolean_t;
|
||||
|
||||
/** ops_content_tag_t */
|
||||
typedef enum ops_content_tag_t ops_content_tag_t;
|
||||
|
||||
typedef struct _ops_crypt_t ops_crypt_t;
|
||||
|
||||
/** ops_hash_t */
|
||||
typedef struct _ops_hash_t ops_hash_t;
|
||||
|
||||
/**
|
||||
keep both ops_content_tag_t and ops_packet_tag_t because we might
|
||||
want to introduce some bounds checking i.e. is this really a valid value
|
||||
for a packet tag?
|
||||
*/
|
||||
typedef enum ops_content_tag_t ops_packet_tag_t;
|
||||
/** SS types are a subset of all content types.
|
||||
*/
|
||||
typedef enum ops_content_tag_t ops_ss_type_t;
|
||||
/* typedef enum ops_sig_type_t ops_sig_type_t; */
|
||||
|
||||
/** Revocation Reason type */
|
||||
typedef unsigned char ops_ss_rr_code_t;
|
||||
|
||||
/** ops_parse_type_t */
|
||||
typedef enum ops_parse_type_t ops_parse_type_t;
|
||||
|
||||
/** ops_parser_content_t */
|
||||
typedef struct ops_parser_content_t ops_parser_content_t;
|
||||
|
||||
/** Reader Flags */
|
||||
/*
|
||||
typedef enum
|
||||
{
|
||||
OPS_RETURN_LENGTH=1,
|
||||
} ops_reader_flags_t;
|
||||
typedef enum ops_reader_ret_t ops_reader_ret_t;
|
||||
*/
|
||||
|
||||
/** Writer flags */
|
||||
typedef enum
|
||||
{
|
||||
OPS_WF_DUMMY,
|
||||
} ops_writer_flags_t;
|
||||
/** ops_writer_ret_t */
|
||||
typedef enum ops_writer_ret_t ops_writer_ret_t;
|
||||
|
||||
/**
|
||||
* \ingroup Create
|
||||
* Contains the required information about how to write
|
||||
*/
|
||||
typedef struct ops_create_info ops_create_info_t;
|
||||
|
||||
#endif
|
||||
54
openpgpsdk/include/openpgpsdk/util.h
Normal file
54
openpgpsdk/include/openpgpsdk/util.h
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
/*
|
||||
* Copyright (c) 2005-2008 Nominet UK (www.nic.uk)
|
||||
* All rights reserved.
|
||||
* Contributors: Ben Laurie, Rachel Willmer. The Contributors have asserted
|
||||
* their moral rights under the UK Copyright Design and Patents Act 1988 to
|
||||
* be recorded as the authors of this copyright work.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||
* use this file except in compliance with the License.
|
||||
*
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
*/
|
||||
|
||||
#ifndef OPS_UTIL_H
|
||||
#define OPS_UTIL_H
|
||||
|
||||
#include "openpgpsdk/types.h"
|
||||
#include "openpgpsdk/create.h"
|
||||
#include "openpgpsdk/packet-parse.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
#define ops_false 0
|
||||
#define ops_true 1
|
||||
|
||||
void hexdump(const unsigned char *src,size_t length);
|
||||
|
||||
/*
|
||||
* These macros code ensures that you are casting what you intend to cast.
|
||||
* It works because in "a ? b : c", b and c must have the same type.
|
||||
* This is a copy of the macro defined in openssl/asn1.h.
|
||||
*/
|
||||
#ifndef CHECKED_PTR_OF
|
||||
#define CHECKED_PTR_OF(type, p) ((void*) (1 ? p : (type *)0))
|
||||
#endif
|
||||
#define CHECKED_INSTANCE_OF(type, p) (1 ? p : (type)0)
|
||||
#define DECONST(type,p) ((type *)CHECKED_PTR_OF(const type, p))
|
||||
|
||||
/* number of elements in an array */
|
||||
#define OPS_ARRAY_SIZE(a) (sizeof(a)/sizeof(*(a)))
|
||||
|
||||
void *ops_mallocz(size_t n);
|
||||
|
||||
#endif
|
||||
102
openpgpsdk/include/openpgpsdk/validate.h
Normal file
102
openpgpsdk/include/openpgpsdk/validate.h
Normal file
|
|
@ -0,0 +1,102 @@
|
|||
/*
|
||||
* Copyright (c) 2005-2008 Nominet UK (www.nic.uk)
|
||||
* All rights reserved.
|
||||
* Contributors: Ben Laurie, Rachel Willmer. The Contributors have asserted
|
||||
* their moral rights under the UK Copyright Design and Patents Act 1988 to
|
||||
* be recorded as the authors of this copyright work.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||
* use this file except in compliance with the License.
|
||||
*
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
unsigned int valid_count;
|
||||
ops_signature_info_t * valid_sigs;
|
||||
unsigned int invalid_count;
|
||||
ops_signature_info_t * invalid_sigs;
|
||||
unsigned int unknown_signer_count;
|
||||
ops_signature_info_t * unknown_sigs;
|
||||
} ops_validate_result_t;
|
||||
|
||||
void ops_validate_result_free(ops_validate_result_t *result);
|
||||
|
||||
ops_boolean_t ops_validate_key_signatures(ops_validate_result_t *result,
|
||||
const ops_keydata_t* keydata,
|
||||
const ops_keyring_t *ring,
|
||||
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 *));
|
||||
|
||||
void ops_keydata_reader_set(ops_parse_info_t *pinfo,
|
||||
const ops_keydata_t *key);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
const ops_keydata_t *key;
|
||||
unsigned packet;
|
||||
unsigned offset;
|
||||
} validate_reader_arg_t;
|
||||
|
||||
/** Struct used with the validate_key_cb callback */
|
||||
typedef struct
|
||||
{
|
||||
ops_public_key_t pkey;
|
||||
ops_public_key_t subkey;
|
||||
ops_secret_key_t skey;
|
||||
enum
|
||||
{
|
||||
ATTRIBUTE=1,
|
||||
ID,
|
||||
} last_seen;
|
||||
ops_user_id_t user_id;
|
||||
ops_user_attribute_t user_attribute;
|
||||
unsigned char hash[OPS_MAX_HASH_SIZE];
|
||||
const ops_keyring_t *keyring;
|
||||
validate_reader_arg_t *rarg;
|
||||
ops_validate_result_t *result;
|
||||
ops_parse_cb_return_t (*cb_get_passphrase) (const ops_parser_content_t *, ops_parse_cb_info_t *);
|
||||
} validate_key_cb_arg_t;
|
||||
|
||||
/** Struct use with the validate_data_cb callback */
|
||||
typedef struct
|
||||
{
|
||||
enum
|
||||
{
|
||||
LITERAL_DATA,
|
||||
SIGNED_CLEARTEXT
|
||||
} use; /*<! this is set to indicate what kind of data we have */
|
||||
union
|
||||
{
|
||||
ops_literal_data_body_t literal_data_body; /*<! Used to hold Literal Data */
|
||||
ops_signed_cleartext_body_t signed_cleartext_body; /*<! Used to hold Signed Cleartext */
|
||||
} data; /*<! the data itself */
|
||||
unsigned char hash[OPS_MAX_HASH_SIZE]; /*<! the hash */
|
||||
const ops_keyring_t *keyring; /*<! keyring to use */
|
||||
validate_reader_arg_t *rarg; /*<! reader-specific arg */
|
||||
ops_validate_result_t *result; /*<! where to put the result */
|
||||
} validate_data_cb_arg_t; /*<! used with validate_data_cb callback */
|
||||
|
||||
ops_boolean_t ops_check_signature(const unsigned char *hash,
|
||||
unsigned length,
|
||||
const ops_signature_t *sig,
|
||||
const ops_public_key_t *signer);
|
||||
ops_parse_cb_return_t
|
||||
ops_validate_key_cb(const ops_parser_content_t *content_,ops_parse_cb_info_t *cbinfo);
|
||||
|
||||
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);
|
||||
|
||||
// EOF
|
||||
39
openpgpsdk/include/openpgpsdk/version.h
Normal file
39
openpgpsdk/include/openpgpsdk/version.h
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
* Copyright (c) 2005-2008 Nominet UK (www.nic.uk)
|
||||
* All rights reserved.
|
||||
* Contributors: Ben Laurie, Rachel Willmer. The Contributors have asserted
|
||||
* their moral rights under the UK Copyright Design and Patents Act 1988 to
|
||||
* be recorded as the authors of this copyright work.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||
* use this file except in compliance with the License.
|
||||
*
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#define OPS_VERSION_MAJOR 0
|
||||
/* Set to the version next to be released */
|
||||
#define OPS_VERSION_MINOR 9
|
||||
/* 0 for development version, 1 for release */
|
||||
#define OPS_VERSION_RELEASE 1
|
||||
|
||||
#define OPS_VERSION ((OPS_VERSION_MAJOR << 16)+(OPS_VERSION_MINOR << 1)+OPS_VERSION_RELEASE)
|
||||
|
||||
#if OPS_VERSION_RELEASE
|
||||
# define OPS_DEV_STRING ""
|
||||
#else
|
||||
# define OPS_DEV_STRING " (dev)"
|
||||
#endif
|
||||
|
||||
|
||||
#define OPS_VERSION_CAT(a,b) "OpenPGP:SDK v" #a "." #b OPS_DEV_STRING
|
||||
#define OPS_VERSION_CAT2(a,b) OPS_VERSION_CAT(a,b)
|
||||
#define OPS_VERSION_STRING OPS_VERSION_CAT2(OPS_VERSION_MAJOR,OPS_VERSION_MINOR)
|
||||
100
openpgpsdk/include/openpgpsdk/writer.h
Normal file
100
openpgpsdk/include/openpgpsdk/writer.h
Normal file
|
|
@ -0,0 +1,100 @@
|
|||
/*
|
||||
* Copyright (c) 2005-2008 Nominet UK (www.nic.uk)
|
||||
* All rights reserved.
|
||||
* Contributors: Ben Laurie, Rachel Willmer. The Contributors have asserted
|
||||
* their moral rights under the UK Copyright Design and Patents Act 1988 to
|
||||
* be recorded as the authors of this copyright work.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||
* use this file except in compliance with the License.
|
||||
*
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
*/
|
||||
|
||||
#ifndef OPS_WRITER_H
|
||||
#define OPS_WRITER_H
|
||||
|
||||
#include "types.h"
|
||||
#include "packet.h"
|
||||
#include "crypto.h"
|
||||
#include "memory.h"
|
||||
#include "errors.h"
|
||||
#include "keyring.h"
|
||||
|
||||
/**
|
||||
* \ingroup Create
|
||||
* This struct contains the required information about one writer
|
||||
*/
|
||||
/**
|
||||
* \ingroup Writer
|
||||
* the writer function prototype
|
||||
*/
|
||||
|
||||
typedef struct ops_writer_info ops_writer_info_t;
|
||||
typedef ops_boolean_t ops_writer_t(const unsigned char *src,
|
||||
unsigned length,
|
||||
ops_error_t **errors,
|
||||
ops_writer_info_t *winfo);
|
||||
typedef ops_boolean_t ops_writer_finaliser_t(ops_error_t **errors,
|
||||
ops_writer_info_t *winfo);
|
||||
typedef void ops_writer_destroyer_t(ops_writer_info_t *winfo);
|
||||
/** Writer settings */
|
||||
struct ops_writer_info
|
||||
{
|
||||
ops_writer_t *writer; /*!< the writer itself */
|
||||
ops_writer_finaliser_t *finaliser; /*!< the writer's finaliser */
|
||||
ops_writer_destroyer_t *destroyer; /*!< the writer's destroyer */
|
||||
void *arg; /* writer-specific argument */
|
||||
ops_writer_info_t *next; /*!< next writer in the stack */
|
||||
};
|
||||
|
||||
|
||||
void *ops_writer_get_arg(ops_writer_info_t *winfo);
|
||||
ops_boolean_t ops_stacked_write(const void *src,unsigned length,
|
||||
ops_error_t **errors,
|
||||
ops_writer_info_t *winfo);
|
||||
|
||||
void ops_writer_set(ops_create_info_t *info,
|
||||
ops_writer_t *writer,
|
||||
ops_writer_finaliser_t *finaliser,
|
||||
ops_writer_destroyer_t *destroyer,
|
||||
void *arg);
|
||||
void ops_writer_push(ops_create_info_t *info,
|
||||
ops_writer_t *writer,
|
||||
ops_writer_finaliser_t *finaliser,
|
||||
ops_writer_destroyer_t *destroyer,
|
||||
void *arg);
|
||||
void ops_writer_pop(ops_create_info_t *info);
|
||||
void ops_writer_generic_destroyer(ops_writer_info_t *winfo);
|
||||
ops_boolean_t ops_writer_passthrough(const unsigned char *src,
|
||||
unsigned length,
|
||||
ops_error_t **errors,
|
||||
ops_writer_info_t *winfo);
|
||||
|
||||
void ops_writer_set_fd(ops_create_info_t *info,int fd);
|
||||
ops_boolean_t ops_writer_close(ops_create_info_t *info);
|
||||
|
||||
ops_boolean_t ops_write(const void *src,unsigned length,
|
||||
ops_create_info_t *opt);
|
||||
ops_boolean_t ops_write_length(unsigned length,ops_create_info_t *opt);
|
||||
ops_boolean_t ops_write_ptag(ops_content_tag_t tag,ops_create_info_t *opt);
|
||||
ops_boolean_t ops_write_scalar(unsigned n,unsigned length,
|
||||
ops_create_info_t *opt);
|
||||
ops_boolean_t ops_write_mpi(const BIGNUM *bn,ops_create_info_t *opt);
|
||||
ops_boolean_t ops_write_encrypted_mpi(const BIGNUM *bn, ops_crypt_t* crypt, ops_create_info_t *info);
|
||||
|
||||
void writer_info_delete(ops_writer_info_t *winfo);
|
||||
ops_boolean_t writer_info_finalise(ops_error_t **errors, ops_writer_info_t *winfo);
|
||||
|
||||
#endif
|
||||
31
openpgpsdk/include/openpgpsdk/writer_armoured.h
Normal file
31
openpgpsdk/include/openpgpsdk/writer_armoured.h
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
* Copyright (c) 2005-2008 Nominet UK (www.nic.uk)
|
||||
* All rights reserved.
|
||||
* Contributors: Ben Laurie, Rachel Willmer. The Contributors have asserted
|
||||
* their moral rights under the UK Copyright Design and Patents Act 1988 to
|
||||
* be recorded as the authors of this copyright work.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||
* use this file except in compliance with the License.
|
||||
*
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <openpgpsdk/armour.h>
|
||||
|
||||
ops_boolean_t ops_writer_push_clearsigned(ops_create_info_t *info,
|
||||
ops_create_signature_t *sig);
|
||||
void ops_writer_push_armoured_message(ops_create_info_t *info);
|
||||
ops_boolean_t ops_writer_switch_to_armoured_signature(ops_create_info_t *info);
|
||||
|
||||
void ops_writer_push_armoured(ops_create_info_t *info, ops_armor_type_t type);
|
||||
|
||||
// EOF
|
||||
Loading…
Add table
Add a link
Reference in a new issue