170
170
gcry_err_code_t gcry_error_from_errno (int err);
173
/* This enum is deprecated; it is only declared for the sake of
174
complete API compatibility. */
173
175
enum gcry_thread_option
175
GCRY_THREAD_OPTION_DEFAULT = 0,
176
GCRY_THREAD_OPTION_USER = 1,
177
GCRY_THREAD_OPTION_PTH = 2,
178
GCRY_THREAD_OPTION_PTHREAD = 3
177
_GCRY_THREAD_OPTION_DUMMY
178
} _GCRY_GCC_ATTR_DEPRECATED;
181
/* Constants defining the thread model to use. Used with the OPTION
182
field of the struct gcry_thread_cbs. */
183
#define GCRY_THREAD_OPTION_DEFAULT 0
184
#define GCRY_THREAD_OPTION_USER 1
185
#define GCRY_THREAD_OPTION_PTH 2
186
#define GCRY_THREAD_OPTION_PTHREAD 3
188
/* The version number encoded in the OPTION field of the struct
190
#define GCRY_THREAD_OPTION_VERSION 0
181
192
/* Wrapper for struct ath_ops. */
182
193
struct gcry_thread_cbs
184
enum gcry_thread_option option;
195
/* The OPTION field encodes the thread model and the version number
197
Bits 7 - 0 are used for the thread model
198
Bits 15 - 8 are used for the version number.
185
202
int (*init) (void);
186
203
int (*mutex_init) (void **priv);
187
204
int (*mutex_destroy) (void **priv);
533
556
enum gcry_mpi_format
535
558
GCRYMPI_FMT_NONE= 0,
536
GCRYMPI_FMT_STD = 1, /* twos complement stored without length */
537
GCRYMPI_FMT_PGP = 2, /* As used by OpenPGP (only defined as unsigned)*/
538
GCRYMPI_FMT_SSH = 3, /* As used by SSH (same as 1 but with length)*/
539
GCRYMPI_FMT_HEX = 4, /* hex format */
540
GCRYMPI_FMT_USG = 5 /* like STD but this is an unsigned one */
559
GCRYMPI_FMT_STD = 1, /* Twos complement stored without length. */
560
GCRYMPI_FMT_PGP = 2, /* As used by OpenPGP (unsigned only). */
561
GCRYMPI_FMT_SSH = 3, /* As used by SSH (like STD but with length). */
562
GCRYMPI_FMT_HEX = 4, /* Hex format. */
563
GCRYMPI_FMT_USG = 5 /* Like STD but unsigned. */
543
566
/* Flags used for creating big integers. */
544
567
enum gcry_mpi_flag
546
GCRYMPI_FLAG_SECURE = 1, /* Allocate the number in "secure" memory. */
547
GCRYMPI_FLAG_OPAQUE = 2 /* The number is not a real one but just a
548
way to store some bytes. This is
549
useful for encrypted big integers. */
569
GCRYMPI_FLAG_SECURE = 1, /* Allocate the number in "secure" memory. */
570
GCRYMPI_FLAG_OPAQUE = 2 /* The number is not a real one but just
571
a way to store some bytes. This is
572
useful for encrypted big integers. */
725
#define mpi_copy( a ) gcry_mpi_copy( (a) )
726
#define mpi_set( w, u) gcry_mpi_set( (w), (u) )
727
#define mpi_set_ui( w, u) gcry_mpi_set_ui( (w), (u) )
728
#define mpi_cmp( u, v ) gcry_mpi_cmp( (u), (v) )
729
#define mpi_cmp_ui( u, v ) gcry_mpi_cmp_ui( (u), (v) )
731
#define mpi_add_ui(w,u,v) gcry_mpi_add_ui((w),(u),(v))
732
#define mpi_add(w,u,v) gcry_mpi_add ((w),(u),(v))
733
#define mpi_addm(w,u,v,m) gcry_mpi_addm ((w),(u),(v),(m))
734
#define mpi_sub_ui(w,u,v) gcry_mpi_sub_ui ((w),(u),(v))
735
#define mpi_sub(w,u,v) gcry_mpi_sub ((w),(u),(v))
736
#define mpi_subm(w,u,v,m) gcry_mpi_subm ((w),(u),(v),(m))
737
#define mpi_mul_ui(w,u,v) gcry_mpi_mul_ui ((w),(u),(v))
738
#define mpi_mul_2exp(w,u,v) gcry_mpi_mul_2exp ((w),(u),(v))
739
#define mpi_mul(w,u,v) gcry_mpi_mul ((w),(u),(v))
740
#define mpi_mulm(w,u,v,m) gcry_mpi_mulm ((w),(u),(v),(m))
741
#define mpi_powm(w,b,e,m) gcry_mpi_powm ( (w), (b), (e), (m) )
742
#define mpi_tdiv(q,r,a,m) gcry_mpi_div ( (q), (r), (a), (m), 0)
743
#define mpi_fdiv(q,r,a,m) gcry_mpi_div ( (q), (r), (a), (m), -1)
744
#define mpi_mod(r,a,m) gcry_mpi_mod ((r), (a), (m))
745
#define mpi_gcd(g,a,b) gcry_mpi_gcd ( (g), (a), (b) )
746
#define mpi_invm(g,a,b) gcry_mpi_invm ( (g), (a), (b) )
751
#define mpi_copy( a ) gcry_mpi_copy( (a) )
752
#define mpi_set( w, u) gcry_mpi_set( (w), (u) )
753
#define mpi_set_ui( w, u) gcry_mpi_set_ui( (w), (u) )
754
#define mpi_cmp( u, v ) gcry_mpi_cmp( (u), (v) )
755
#define mpi_cmp_ui( u, v ) gcry_mpi_cmp_ui( (u), (v) )
757
#define mpi_add_ui(w,u,v) gcry_mpi_add_ui((w),(u),(v))
758
#define mpi_add(w,u,v) gcry_mpi_add ((w),(u),(v))
759
#define mpi_addm(w,u,v,m) gcry_mpi_addm ((w),(u),(v),(m))
760
#define mpi_sub_ui(w,u,v) gcry_mpi_sub_ui ((w),(u),(v))
761
#define mpi_sub(w,u,v) gcry_mpi_sub ((w),(u),(v))
762
#define mpi_subm(w,u,v,m) gcry_mpi_subm ((w),(u),(v),(m))
763
#define mpi_mul_ui(w,u,v) gcry_mpi_mul_ui ((w),(u),(v))
764
#define mpi_mul_2exp(w,u,v) gcry_mpi_mul_2exp ((w),(u),(v))
765
#define mpi_mul(w,u,v) gcry_mpi_mul ((w),(u),(v))
766
#define mpi_mulm(w,u,v,m) gcry_mpi_mulm ((w),(u),(v),(m))
767
#define mpi_powm(w,b,e,m) gcry_mpi_powm ( (w), (b), (e), (m) )
768
#define mpi_tdiv(q,r,a,m) gcry_mpi_div ( (q), (r), (a), (m), 0)
769
#define mpi_fdiv(q,r,a,m) gcry_mpi_div ( (q), (r), (a), (m), -1)
770
#define mpi_mod(r,a,m) gcry_mpi_mod ((r), (a), (m))
771
#define mpi_gcd(g,a,b) gcry_mpi_gcd ( (g), (a), (b) )
772
#define mpi_invm(g,a,b) gcry_mpi_invm ( (g), (a), (b) )
748
774
#define mpi_get_nbits(a) gcry_mpi_get_nbits ((a))
749
775
#define mpi_test_bit(a,b) gcry_mpi_test_bit ((a),(b))
752
778
#define mpi_clear_bit(a,b) gcry_mpi_clear_bit ((a),(b))
753
779
#define mpi_clear_highbit(a,b) gcry_mpi_clear_highbit ((a),(b))
754
780
#define mpi_rshift(a,b,c) gcry_mpi_rshift ((a),(b),(c))
781
#define mpi_lshift(a,b,c) gcry_mpi_lshift ((a),(b),(c))
756
#define mpi_set_opaque(a,b,c) gcry_mpi_set_opaque( (a), (b), (c) )
757
#define mpi_get_opaque(a,b) gcry_mpi_get_opaque( (a), (b) )
783
#define mpi_set_opaque(a,b,c) gcry_mpi_set_opaque( (a), (b), (c) )
784
#define mpi_get_opaque(a,b) gcry_mpi_get_opaque( (a), (b) )
758
785
#endif /* GCRYPT_NO_MPI_MACROS */
762
789
/************************************
764
* symmetric cipher functions *
791
* Symmetric Cipher Functions *
766
793
************************************/
882
909
void *out, size_t outsize,
883
910
const void *in, size_t inlen);
885
/* Set key K of length L for the cipher handle H. (We have to cast
886
away a const char* here - this catch-all ctl function was probably
887
not the best choice) */
888
#define gcry_cipher_setkey(h,k,l) gcry_cipher_ctl( (h), GCRYCTL_SET_KEY, \
891
/* Set initialization vector K of length L for the cipher handle H. */
892
#define gcry_cipher_setiv(h,k,l) gcry_cipher_ctl( (h), GCRYCTL_SET_IV, \
912
/* Set KEY of length KEYLEN for the cipher handle HD. */
913
gcry_error_t gcry_cipher_setkey (gcry_cipher_hd_t hd,
914
const void *key, size_t keylen);
917
/* Set initialization vector IV of length IVLEN for the cipher handle HD. */
918
gcry_error_t gcry_cipher_setiv (gcry_cipher_hd_t hd,
919
const void *iv, size_t ivlen);
895
922
/* Reset the handle to the state after open. */
896
923
#define gcry_cipher_reset(h) gcry_cipher_ctl ((h), GCRYCTL_RESET, NULL, 0)
898
/* Perform the the OpenPGP sync operation if this is enabled for the
925
/* Perform the OpenPGP sync operation if this is enabled for the
899
926
cipher handle H. */
900
#define gcry_cipher_sync(h) gcry_cipher_ctl( (h), GCRYCTL_CFB_SYNC, \
927
#define gcry_cipher_sync(h) gcry_cipher_ctl( (h), GCRYCTL_CFB_SYNC, NULL, 0)
903
929
/* Enable or disable CTS in future calls to gcry_encrypt(). CBC mode only. */
904
930
#define gcry_cipher_cts(h,on) gcry_cipher_ctl( (h), GCRYCTL_SET_CBC_CTS, \
907
/* Set counter for CTR mode. (K,L) must denote a buffer of block size
908
length, or (NULL,0) to set the CTR to the all-zero block. */
909
#define gcry_cipher_setctr(h,k,l) gcry_cipher_ctl( (h), GCRYCTL_SET_CTR, \
933
/* Set counter for CTR mode. (CTR,CTRLEN) must denote a buffer of
934
block size length, or (NULL,0) to set the CTR to the all-zero block. */
935
gpg_error_t gcry_cipher_setctr (gcry_cipher_hd_t hd,
936
const void *ctr, size_t ctrlen);
912
938
/* Retrieved the key length used with algorithm A. */
913
939
size_t gcry_cipher_get_algo_keylen (int algo);