summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>1999-11-13 17:43:23 +0100
committerWerner Koch <wk@gnupg.org>1999-11-13 17:43:23 +0100
commit881e51323749ba797202d8a4119910e6f9d2f727 (patch)
tree3de535d07143b9b3513b524dd81f32a5305756b1 /include
parentSee ChangeLog: Thu Oct 28 16:17:46 CEST 1999 Werner Koch (diff)
downloadgnupg2-881e51323749ba797202d8a4119910e6f9d2f727.tar.xz
gnupg2-881e51323749ba797202d8a4119910e6f9d2f727.zip
See ChangeLog: Sat Nov 13 17:44:23 CET 1999 Werner Koch
Diffstat (limited to 'include')
-rw-r--r--include/cipher.h2
-rw-r--r--include/errors.h105
-rw-r--r--include/g10lib.h187
3 files changed, 89 insertions, 205 deletions
diff --git a/include/cipher.h b/include/cipher.h
index 9e1fba874..aaab08d55 100644
--- a/include/cipher.h
+++ b/include/cipher.h
@@ -45,8 +45,10 @@
#define PUBKEY_ALGO_DSA 17
#define PUBKEY_ALGO_ELGAMAL 20 /* sign and encrypt elgamal */
+#if 0
#define PUBKEY_USAGE_SIG 1 /* key is good for signatures */
#define PUBKEY_USAGE_ENC 2 /* key is good for encryption */
+#endif
#define DIGEST_ALGO_MD5 1
#define DIGEST_ALGO_SHA1 2
diff --git a/include/errors.h b/include/errors.h
index 247951271..a126e2636 100644
--- a/include/errors.h
+++ b/include/errors.h
@@ -20,57 +20,60 @@
#ifndef G10_ERRORS_H
#define G10_ERRORS_H
-#define G10ERR_GENERAL 1
-#define G10ERR_UNKNOWN_PACKET 2
-#define G10ERR_UNKNOWN_VERSION 3 /* Unknown version (in packet) */
-#define G10ERR_PUBKEY_ALGO 4 /* Unknown pubkey algorithm */
-#define G10ERR_DIGEST_ALGO 5 /* Unknown digest algorithm */
-#define G10ERR_BAD_PUBKEY 6 /* Bad public key */
-#define G10ERR_BAD_SECKEY 7 /* Bad secret key */
-#define G10ERR_BAD_SIGN 8 /* Bad signature */
-#define G10ERR_NO_PUBKEY 9 /* public key not found */
-#define G10ERR_CHECKSUM 10 /* checksum error */
-#define G10ERR_BAD_PASS 11 /* Bad passphrase */
-#define G10ERR_CIPHER_ALGO 12 /* Unknown cipher algorithm */
-#define G10ERR_KEYRING_OPEN 13
-#define G10ERR_INVALID_PACKET 14
-#define G10ERR_INVALID_ARMOR 15
-#define G10ERR_NO_USER_ID 16
-#define G10ERR_NO_SECKEY 17 /* secret key not available */
-#define G10ERR_WRONG_SECKEY 18 /* wrong seckey used */
-#define G10ERR_UNSUPPORTED 19
-#define G10ERR_BAD_KEY 20 /* bad (session) key */
-#define G10ERR_READ_FILE 21
-#define G10ERR_WRITE_FILE 22
-#define G10ERR_COMPR_ALGO 23 /* Unknown compress algorithm */
-#define G10ERR_OPEN_FILE 24
-#define G10ERR_CREATE_FILE 25
-#define G10ERR_PASSPHRASE 26 /* invalid passphrase */
-#define G10ERR_NI_PUBKEY 27
-#define G10ERR_NI_CIPHER 28
-#define G10ERR_SIG_CLASS 29
-#define G10ERR_BAD_MPI 30
-#define G10ERR_RESOURCE_LIMIT 31
-#define G10ERR_INV_KEYRING 32
-#define G10ERR_TRUSTDB 33 /* a problem with the trustdb */
-#define G10ERR_BAD_CERT 34 /* bad certicate */
-#define G10ERR_INV_USER_ID 35
-#define G10ERR_CLOSE_FILE 36
-#define G10ERR_RENAME_FILE 37
-#define G10ERR_DELETE_FILE 38
-#define G10ERR_UNEXPECTED 39
-#define G10ERR_TIME_CONFLICT 40
-#define G10ERR_WR_PUBKEY_ALGO 41 /* unusabe pubkey algo */
-#define G10ERR_FILE_EXISTS 42
-#define G10ERR_WEAK_KEY 43 /* NOTE: hardcoded into the cipher modules */
-#define G10ERR_WRONG_KEYLEN 44 /* NOTE: hardcoded into the cipher modules */
-#define G10ERR_INV_ARG 45
-#define G10ERR_BAD_URI 46 /* syntax error in URI */
-#define G10ERR_INVALID_URI 47 /* e.g. unsupported scheme */
-#define G10ERR_NETWORK 48 /* general network error */
-#define G10ERR_UNKNOWN_HOST 49
-#define G10ERR_SELFTEST_FAILED 50
-#define G10ERR_NOT_ENCRYPTED 51
+
+/* FIXME: some constants have to be the same as the ones from
+ * libgcrypt - include gcrypt.h and use those constants */
+#define G10ERR_GENERAL 101
+#define G10ERR_UNKNOWN_PACKET 102
+#define G10ERR_UNKNOWN_VERSION 103 /* Unknown version (in packet) */
+#define G10ERR_PUBKEY_ALGO 4 /* Unknown pubkey algorithm */
+#define G10ERR_DIGEST_ALGO 5 /* Unknown digest algorithm */
+#define G10ERR_BAD_PUBKEY 6 /* Bad public key */
+#define G10ERR_BAD_SECKEY 7 /* Bad secret key */
+#define G10ERR_BAD_SIGN 8 /* Bad signature */
+#define G10ERR_NO_PUBKEY 109 /* public key not found */
+#define G10ERR_CHECKSUM 110 /* checksum error */
+#define G10ERR_BAD_PASS 111 /* Bad passphrase */
+#define G10ERR_CIPHER_ALGO 12 /* Unknown cipher algorithm */
+#define G10ERR_KEYRING_OPEN 113
+#define G10ERR_INVALID_PACKET 114
+#define G10ERR_INVALID_ARMOR 115
+#define G10ERR_NO_USER_ID 116
+#define G10ERR_NO_SECKEY 117 /* secret key not available */
+#define G10ERR_WRONG_SECKEY 118 /* wrong seckey used */
+#define G10ERR_UNSUPPORTED 119
+#define G10ERR_BAD_KEY 120 /* bad (session) key */
+#define G10ERR_READ_FILE 121
+#define G10ERR_WRITE_FILE 122
+#define G10ERR_COMPR_ALGO 123 /* Unknown compress algorithm */
+#define G10ERR_OPEN_FILE 124
+#define G10ERR_CREATE_FILE 125
+#define G10ERR_PASSPHRASE 126 /* invalid passphrase */
+#define G10ERR_NI_PUBKEY 127
+#define G10ERR_NI_CIPHER 128
+#define G10ERR_SIG_CLASS 129
+#define G10ERR_BAD_MPI 30
+#define G10ERR_RESOURCE_LIMIT 131
+#define G10ERR_INV_KEYRING 132
+#define G10ERR_TRUSTDB 133 /* a problem with the trustdb */
+#define G10ERR_BAD_CERT 134 /* bad certicate */
+#define G10ERR_INV_USER_ID 135
+#define G10ERR_CLOSE_FILE 136
+#define G10ERR_RENAME_FILE 137
+#define G10ERR_DELETE_FILE 138
+#define G10ERR_UNEXPECTED 139
+#define G10ERR_TIME_CONFLICT 140
+#define G10ERR_WR_PUBKEY_ALGO 41 /* unusabe pubkey algo */
+#define G10ERR_FILE_EXISTS 142
+#define G10ERR_WEAK_KEY 43 /* NOTE: hardcoded into the cipher modules */
+#define G10ERR_WRONG_KEYLEN 44 /* NOTE: hardcoded into the cipher modules */
+#define G10ERR_INV_ARG 145
+#define G10ERR_BAD_URI 146 /* syntax error in URI */
+#define G10ERR_INVALID_URI 147 /* e.g. unsupported scheme */
+#define G10ERR_NETWORK 148 /* general network error */
+#define G10ERR_UNKNOWN_HOST 149
+#define G10ERR_SELFTEST_FAILED 50
+#define G10ERR_NOT_ENCRYPTED 151
#ifndef HAVE_STRERROR
char *strerror( int n );
diff --git a/include/g10lib.h b/include/g10lib.h
index 38bd63128..ee04b655c 100644
--- a/include/g10lib.h
+++ b/include/g10lib.h
@@ -41,172 +41,51 @@
/*-- gcrypt/global.c --*/
int set_lasterr( int ec );
-/*-- gcrypt/misc.c --*/
-const char *g10_gettext( const char *key );
-int fatal_invalid_arg(const char *text);
-
-#if 0
-/* This used to be the old include/g10lib.h */
-
-#include "mpi.h"
-
-int g10c_debug_mode;
-int g10_opt_verbose;
-
-/********************************
- ******* math functions *******
- ********************************/
-MPI g10m_new( unsigned nbits );
-MPI g10m_new_secure( unsigned nbits );
-void g10m_release( MPI a );
-void g10m_resize( MPI a, unsigned nbits );
-MPI g10m_copy( MPI a );
-void g10m_swap( MPI a, MPI b);
-void g10m_set( MPI w, MPI u);
-void g10m_set_ui( MPI w, unsigned long u);
-void g10m_set_bytes( MPI a, unsigned nbits, unsigned char (*fnc)(int), int opaque );
-int g10m_cmp( MPI u, MPI v );
-int g10m_cmp_ui( MPI u, unsigned long v );
-
-
-void g10m_add(MPI w, MPI u, MPI v);
-void g10m_add_ui(MPI w, MPI u, unsigned long v );
-void g10m_sub( MPI w, MPI u, MPI v);
-void g10m_sub_ui(MPI w, MPI u, unsigned long v );
-
-void g10m_mul_ui(MPI w, MPI u, unsigned long v );
-void g10m_mul_2exp( MPI w, MPI u, unsigned long cnt);
-void g10m_mul( MPI w, MPI u, MPI v);
-void g10m_mulm( MPI w, MPI u, MPI v, MPI m);
-
-void g10m_fdiv_q( MPI quot, MPI dividend, MPI divisor );
-
-void g10m_powm( MPI res, MPI base, MPI exp, MPI mod);
-
-int g10m_gcd( MPI g, MPI a, MPI b );
-int g10m_invm( MPI x, MPI u, MPI v );
-
-unsigned g10m_get_nbits( MPI a );
-unsigned g10m_get_size( MPI a );
-
-void g10m_set_buffer( MPI a, const char *buffer, unsigned nbytes, int sign );
-
-
-/********************************************
- ******* symmetric cipher functions *******
- ********************************************/
-
-
-
-/*********************************************
- ******* asymmetric cipher functions *******
- *********************************************/
-
-
-
-
-/*********************************************
- ******* cryptograhic hash functions *******
- *********************************************/
-
-
-/*****************************************
- ******* miscellaneous functions *******
- *****************************************/
-
-const char *g10m_revision_string(int mode);
-const char *g10c_revision_string(int mode);
-const char *g10u_revision_string(int mode);
-
-MPI g10c_generate_secret_prime( unsigned nbits );
-char *g10c_get_random_bits( unsigned nbits, int level, int secure );
-
void *g10_malloc( size_t n );
-void *g10_calloc( size_t n );
+void *g10_calloc( size_t n, size_t m );
void *g10_malloc_secure( size_t n );
-void *g10_calloc_secure( size_t n );
+void *g10_calloc_secure( size_t n, size_t m );
void *g10_realloc( void *a, size_t n );
-void g10_free( void *p );
char *g10_strdup( const char * a);
+void *g10_xmalloc( size_t n );
+void *g10_xcalloc( size_t n, size_t m );
+void *g10_xmalloc_secure( size_t n );
+void *g10_xcalloc_secure( size_t n, size_t m );
+void *g10_xrealloc( void *a, size_t n );
+char *g10_xstrdup( const char * a);
+void g10_free( void *p );
-void g10_log_bug( const char *fmt, ... );
-void g10_log_bug0( const char *, int );
-void g10_log_fatal( const char *fmt, ... );
-void g10_log_error( const char *fmt, ... );
-void g10_log_info( const char *fmt, ... );
-void g10_log_debug( const char *fmt, ... );
-void g10_log_hexdump( const char *text, char *buf, size_t len );
-void g10_log_mpidump( const char *text, MPI a );
-
-
-/***************************
- ******* constants *******
- **************************/
-#define CIPHER_ALGO_NONE 0
-#define CIPHER_ALGO_IDEA 1
-#define CIPHER_ALGO_3DES 2
-#define CIPHER_ALGO_CAST5 3
-#define CIPHER_ALGO_BLOWFISH 4 /* blowfish 128 bit key */
-#define CIPHER_ALGO_SAFER_SK128 5
-#define CIPHER_ALGO_DES_SK 6
-#define CIPHER_ALGO_BLOWFISH160 42 /* blowfish 160 bit key (not in OpenPGP)*/
-#define CIPHER_ALGO_DUMMY 110 /* no encryption at all */
-
-#define PUBKEY_ALGO_RSA 1
-#define PUBKEY_ALGO_RSA_E 2 /* RSA encrypt only */
-#define PUBKEY_ALGO_RSA_S 3 /* RSA sign only */
-#define PUBKEY_ALGO_ELGAMAL_E 16 /* encrypt only ElGamal (but not vor v3)*/
-#define PUBKEY_ALGO_DSA 17
-#define PUBKEY_ALGO_ELGAMAL 20 /* sign and encrypt elgamal */
-
-#define DIGEST_ALGO_MD5 1
-#define DIGEST_ALGO_SHA1 2
-#define DIGEST_ALGO_RMD160 3
-#define DIGEST_ALGO_TIGER 6
-
-#define is_RSA(a) ((a)==PUBKEY_ALGO_RSA || (a)==PUBKEY_ALGO_RSA_E \
- || (a)==PUBKEY_ALGO_RSA_S )
-#define is_ELGAMAL(a) ((a)==PUBKEY_ALGO_ELGAMAL || (a)==PUBKEY_ALGO_ELGAMAL_E)
-
-#define G10ERR_GENERAL 1
-#define G10ERR_PUBKEY_ALGO 4
-#define G10ERR_DIGEST_ALGO 5
-#define G10ERR_BAD_PUBKEY 6
-#define G10ERR_BAD_SECKEY 7
-#define G10ERR_BAD_SIGN 8
-#define G10ERR_CIPHER_ALGO 12
-#define G10ERR_WRONG_SECKEY 18
-#define G10ERR_UNSUPPORTED 19
-#define G10ERR_NI_PUBKEY 27
-#define G10ERR_NI_CIPHER 28
-#define G10ERR_BAD_MPI 30
-#define G10ERR_WR_PUBKEY_ALGO 41
-
-
-/***********************************
- ******* some handy macros *******
- ***********************************/
-
-#ifndef BUG
- #define BUG() g10_log_bug0( __FILE__ , __LINE__ )
-#endif
-#ifndef STR
- #define STR(v) #v
- #define STR2(v) STR(v)
-#endif
+/*-- gcrypt/misc.c --*/
+const char *g10_gettext( const char *key );
+int fatal_invalid_arg(const char *text);
-#ifndef DIM
- #define DIM(v) (sizeof(v)/sizeof((v)[0]))
- #define DIMof(type,member) DIM(((type *)0)->member)
+
+/*-- cipher/pubkey.c --*/
+
+#ifndef DID_MPI_TYPEDEF
+ typedef struct gcry_mpi * MPI;
+ #define DID_MPI_TYPEDEF
#endif
+int string_to_pubkey_algo( const char *string );
+const char * pubkey_algo_to_string( int algo );
+unsigned pubkey_nbits( int algo, MPI *pkey );
+int pubkey_generate( int algo, unsigned nbits, MPI *skey, MPI **retfactors );
+int pubkey_check_secret_key( int algo, MPI *skey );
+int pubkey_encrypt( int algo, MPI *resarr, MPI data, MPI *pkey );
+int pubkey_decrypt( int algo, MPI *result, MPI *data, MPI *skey );
+
+
+
-#define DBG_CIPHER g10c_debug_mode
-#define OPT_VERBOSE g10_opt_verbose
+/*-- primegen.c --*/
+MPI generate_secret_prime( unsigned nbits );
+MPI generate_public_prime( unsigned nbits );
+MPI generate_elg_prime( int mode, unsigned pbits, unsigned qbits,
+ MPI g, MPI **factors );
-#endif /* if 0 */
#endif /* G10LIB_H */