summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>1998-06-16 17:13:28 +0200
committerWerner Koch <wk@gnupg.org>1998-06-16 17:13:28 +0200
commite6ac5acbbf56ed8995bfa4d5a28160fa3a5d825f (patch)
tree6ff27595e33dd57d3a8979d245236bd5f404c9b4 /include
parentextensions are now working and fixed a lot of bugs (diff)
downloadgnupg2-e6ac5acbbf56ed8995bfa4d5a28160fa3a5d825f.tar.xz
gnupg2-e6ac5acbbf56ed8995bfa4d5a28160fa3a5d825f.zip
some more internall structure changes
Diffstat (limited to 'include')
-rw-r--r--include/cipher.h56
-rw-r--r--include/errors.h8
-rw-r--r--include/g10lib.h16
-rw-r--r--include/i18n.h8
-rw-r--r--include/iobuf.h8
-rw-r--r--include/memory.h8
-rw-r--r--include/mpi.h9
-rw-r--r--include/ttyio.h8
-rw-r--r--include/types.h8
-rw-r--r--include/util.h50
10 files changed, 122 insertions, 57 deletions
diff --git a/include/cipher.h b/include/cipher.h
index 6481ceeda..8544ee2e0 100644
--- a/include/cipher.h
+++ b/include/cipher.h
@@ -1,19 +1,14 @@
/* cipher.h
- * Copyright (c) 1997 by Werner Koch (dd9jn)
+ * Copyright (C) 1998 Free Software Foundation, Inc.
*
- * ATTENTION: This code should not be exported from the United States
- * nor should it be used their without a license agreement with PKP.
- * The RSA alorithm is protected by U.S. Patent #4,405,829 which
- * expires on September 20, 2000!
+ * This file is part of GNUPG.
*
- * This file is part of G10.
- *
- * G10 is free software; you can redistribute it and/or modify
+ * GNUPG is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
- * G10 is distributed in the hope that it will be useful,
+ * GNUPG is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
@@ -28,7 +23,6 @@
#define DBG_CIPHER g10c_debug_mode
#include "mpi.h"
-#include "../cipher/md.h"
#include "../cipher/random.h"
@@ -77,12 +71,54 @@ struct cipher_handle_s { char does_not_matter[1]; };
#define CIPHER_MODE_DUMMY 5 /* used with algo DUMMY for no encryption */
+#define MD_BUFFER_SIZE 512
+
+typedef struct {
+ byte buffer[MD_BUFFER_SIZE];
+ int bufcount;
+ int secure;
+ FILE *debug;
+ struct md_digest_list_s *list;
+} *MD_HANDLE;
+
+
+#ifndef DEFINES_MD_HANDLE /* not really the handle but the algorithm list */
+struct md_digest_list_s { char does_not_matter[1]; };
+#endif
+
+
+
int g10c_debug_mode;
int g10_opt_verbose;
/*-- dynload.c --*/
void register_cipher_extension( const char *fname );
+/*-- md.c --*/
+int string_to_digest_algo( const char *string );
+const char * digest_algo_to_string( int algo );
+int check_digest_algo( int algo );
+MD_HANDLE md_open( int algo, int secure );
+void md_enable( MD_HANDLE hd, int algo );
+MD_HANDLE md_copy( MD_HANDLE a );
+void md_close(MD_HANDLE a);
+void md_write( MD_HANDLE a, byte *inbuf, size_t inlen);
+void md_final(MD_HANDLE a);
+byte *md_read( MD_HANDLE a, int algo );
+int md_get_algo( MD_HANDLE a );
+int md_digest_length( int algo );
+const byte *md_asn_oid( int algo, size_t *asnlen, size_t *mdlen );
+void md_start_debug( MD_HANDLE a, const char *suffix );
+void md_stop_debug( MD_HANDLE a );
+#define md_is_secure(a) ((a)->secure)
+#define md_putc(h,c) \
+ do { \
+ if( (h)->bufcount == MD_BUFFER_SIZE ) \
+ md_write( (h), NULL, 0 ); \
+ (h)->buffer[(h)->bufcount++] = (c) & 0xff; \
+ } while(0)
+
+
/*-- cipher.c --*/
int string_to_cipher_algo( const char *string );
const char * cipher_algo_to_string( int algo );
diff --git a/include/errors.h b/include/errors.h
index dc7486598..f2ec2073b 100644
--- a/include/errors.h
+++ b/include/errors.h
@@ -1,14 +1,14 @@
/* errors.h - erro code
- * Copyright (c) 1997 by Werner Koch (dd9jn)
+ * Copyright (C) 1998 Free Software Foundation, Inc.
*
- * This file is part of G10.
+ * This file is part of GNUPG.
*
- * G10 is free software; you can redistribute it and/or modify
+ * GNUPG is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
- * G10 is distributed in the hope that it will be useful,
+ * GNUPG is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
diff --git a/include/g10lib.h b/include/g10lib.h
index 338737831..fe144add5 100644
--- a/include/g10lib.h
+++ b/include/g10lib.h
@@ -1,7 +1,21 @@
/* g10lib.h - GNU digital encryption libray interface
* Copyright (C) 1998 Free Software Foundation, Inc.
*
- * FIXME: This should allow XFree programs etc to use the header.
+ * This file is part of GNUPG.
+ *
+ * GNUPG is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * GNUPG is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifndef _g10lib_G10LIB_H
diff --git a/include/i18n.h b/include/i18n.h
index 4a0f1ac78..105a64328 100644
--- a/include/i18n.h
+++ b/include/i18n.h
@@ -1,14 +1,14 @@
/* i18n.h
- * Copyright (c) 1998 by Werner Koch (dd9jn)
+ * Copyright (C) 1998 Free Software Foundation, Inc.
*
- * This file is part of G10.
+ * This file is part of GNUPG.
*
- * G10 is free software; you can redistribute it and/or modify
+ * GNUPG is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
- * G10 is distributed in the hope that it will be useful,
+ * GNUPG is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
diff --git a/include/iobuf.h b/include/iobuf.h
index 61c765395..7fd4f7bd1 100644
--- a/include/iobuf.h
+++ b/include/iobuf.h
@@ -1,14 +1,14 @@
/* iobuf.h - I/O buffer
- * Copyright (c) 1997 by Werner Koch (dd9jn)
+ * Copyright (C) 1998 Free Software Foundation, Inc.
*
- * This file is part of G10.
+ * This file is part of GNUPG.
*
- * G10 is free software; you can redistribute it and/or modify
+ * GNUPG is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
- * G10 is distributed in the hope that it will be useful,
+ * GNUPG is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
diff --git a/include/memory.h b/include/memory.h
index d9dd295a9..08bccd5ec 100644
--- a/include/memory.h
+++ b/include/memory.h
@@ -1,14 +1,14 @@
/* memory.h - memory allocation
- * Copyright (c) 1997 by Werner Koch (dd9jn)
+ * Copyright (C) 1998 Free Software Foundation, Inc.
*
- * This file is part of G10.
+ * This file is part of GNUPG.
*
- * G10 is free software; you can redistribute it and/or modify
+ * GNUPG is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
- * G10 is distributed in the hope that it will be useful,
+ * GNUPG is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
diff --git a/include/mpi.h b/include/mpi.h
index 9d93d8505..6e0e42eaa 100644
--- a/include/mpi.h
+++ b/include/mpi.h
@@ -48,7 +48,8 @@ typedef struct mpi_struct {
int nlimbs; /* number of valid limbs */
int nbits; /* the real number of valid bits (info only) */
int sign; /* indicates a negative number */
- int secure; /* array must be allocated in secure memory space */
+ unsigned flags; /* bit 0: array must be allocated in secure memory space */
+ /* bit 1: the mpi is encrypted */
mpi_limb_t *d; /* array with the limbs */
} *MPI;
@@ -56,6 +57,7 @@ typedef struct mpi_struct {
#define mpi_get_nlimbs(a) ((a)->nlimbs)
#define mpi_get_nbit_info(a) ((a)->nbits)
+#define mpi_set_nbit_info(a,b) ((a)->nbits = (b))
#define mpi_is_neg(a) ((a)->sign)
/*-- mpiutil.c --*/
@@ -78,7 +80,10 @@ typedef struct mpi_struct {
void mpi_resize( MPI a, unsigned nlimbs );
MPI mpi_copy( MPI a );
#endif
-#define mpi_is_secure(a) ((a) && (a)->secure)
+#define mpi_is_protected(a) ((a) && ((a)->flags&2))
+#define mpi_set_protect_flag(a) ((a)->flags |= 2)
+#define mpi_clear_protect_flag(a) ((a)->flags &= ~2)
+#define mpi_is_secure(a) ((a) && ((a)->flags&1))
void mpi_set_secure( MPI a );
void mpi_clear( MPI a );
void mpi_set( MPI w, MPI u);
diff --git a/include/ttyio.h b/include/ttyio.h
index 6d599870f..2949cfd19 100644
--- a/include/ttyio.h
+++ b/include/ttyio.h
@@ -1,14 +1,14 @@
/* ttyio.h
- * Copyright (c) 1997 by Werner Koch (dd9jn)
+ * Copyright (C) 1998 Free Software Foundation, Inc.
*
- * This file is part of G10.
+ * This file is part of GNUPG.
*
- * G10 is free software; you can redistribute it and/or modify
+ * GNUPG is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
- * G10 is distributed in the hope that it will be useful,
+ * GNUPG is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
diff --git a/include/types.h b/include/types.h
index 543cbad62..328a1a93c 100644
--- a/include/types.h
+++ b/include/types.h
@@ -1,14 +1,14 @@
/* types.h - some common typedefs
- * Copyright (c) 1997 by Werner Koch (dd9jn)
+ * Copyright (C) 1998 Free Software Foundation, Inc.
*
- * This file is part of G10.
+ * This file is part of GNUPG.
*
- * G10 is free software; you can redistribute it and/or modify
+ * GNUPG is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
- * G10 is distributed in the hope that it will be useful,
+ * GNUPG is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
diff --git a/include/util.h b/include/util.h
index 3dec01cdd..24fea1260 100644
--- a/include/util.h
+++ b/include/util.h
@@ -1,14 +1,14 @@
/* util.h
- * Copyright (c) 1997 by Werner Koch (dd9jn)
+ * Copyright (C) 1998 Free Software Foundation, Inc.
*
- * This file is part of G10.
+ * This file is part of GNUPG.
*
- * G10 is free software; you can redistribute it and/or modify
+ * GNUPG is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
- * G10 is distributed in the hope that it will be useful,
+ * GNUPG is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
@@ -60,29 +60,39 @@ void log_set_name( const char *name );
const char *log_get_name(void);
void log_set_pid( int pid );
int log_get_errorcount( int clear );
-void log_hexdump( const char *text, char *buf, size_t len );
-void log_mpidump( const char *text, MPI a );
+void g10_log_hexdump( const char *text, char *buf, size_t len );
+void g10_log_mpidump( const char *text, MPI a );
#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 5 )
- void log_bug( const char *fmt, ... )
+ void g10_log_bug( const char *fmt, ... )
__attribute__ ((noreturn, format (printf,1,2)));
- void log_bug0( const char *, int, const char * ) __attribute__ ((noreturn));
- void log_fatal( const char *fmt, ... )
+ void g10_log_bug0( const char *, int, const char * ) __attribute__ ((noreturn));
+ void g10_log_fatal( const char *fmt, ... )
__attribute__ ((noreturn, format (printf,1,2)));
- void log_error( const char *fmt, ... ) __attribute__ ((format (printf,1,2)));
- void log_info( const char *fmt, ... ) __attribute__ ((format (printf,1,2)));
- void log_debug( const char *fmt, ... ) __attribute__ ((format (printf,1,2)));
- #define BUG() log_bug0( __FILE__ , __LINE__, __FUNCTION__ )
+ void g10_log_error( const char *fmt, ... ) __attribute__ ((format (printf,1,2)));
+ void g10_log_info( const char *fmt, ... ) __attribute__ ((format (printf,1,2)));
+ void g10_log_debug( const char *fmt, ... ) __attribute__ ((format (printf,1,2)));
+ #define BUG() g10_log_bug0( __FILE__ , __LINE__, __FUNCTION__ )
#else
- void log_bug( const char *fmt, ... );
- void log_bug0( const char *, int );
- void log_fatal( const char *fmt, ... );
- void log_error( const char *fmt, ... );
- void log_info( const char *fmt, ... );
- void log_debug( const char *fmt, ... );
- #define BUG() log_bug0( __FILE__ , __LINE__ )
+ 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, ... );
+ #define BUG() g10_log_bug0( __FILE__ , __LINE__ )
#endif
+#define log_hexdump g10_log_hexdump
+#define log_mpidump g10_log_mpidump
+#define log_bug g10_log_bug
+#define log_bug0 g10_log_bug0
+#define log_fatal g10_log_fatal
+#define log_error g10_log_error
+#define log_info g10_log_info
+#define log_debug g10_log_debug
+
+
/*-- errors.c --*/
const char * g10_errstr( int no );