1
1
/* visibility.c - Wrapper for all public functions.
2
* Copyright (C) 2007 Free Software Foundation, Inc.
2
* Copyright (C) 2007, 2008 Free Software Foundation, Inc.
4
4
* This file is part of Libgcrypt.
455
457
_gcry_mpi_rshift (x, a, n);
461
gcry_mpi_lshift (gcry_mpi_t x, gcry_mpi_t a, unsigned int n)
463
_gcry_mpi_lshift (x, a, n);
459
467
gcry_mpi_set_opaque (gcry_mpi_t a, void *p, unsigned int nbits)
489
497
gcry_cipher_open (gcry_cipher_hd_t *handle,
490
498
int algo, int mode, unsigned int flags)
500
if (!fips_is_operational ())
503
return gpg_error (fips_not_operational ());
492
506
return _gcry_cipher_open (handle, algo, mode, flags);
516
gcry_cipher_setkey (gcry_cipher_hd_t hd, const void *key, size_t keylen)
518
if (!fips_is_operational ())
519
return gpg_error (fips_not_operational ());
521
return _gcry_cipher_setkey (hd, key, keylen);
525
gcry_cipher_setiv (gcry_cipher_hd_t hd, const void *iv, size_t ivlen)
527
if (!fips_is_operational ())
528
return gpg_error (fips_not_operational ());
530
return _gcry_cipher_setiv (hd, iv, ivlen);
534
gcry_cipher_setctr (gcry_cipher_hd_t hd, const void *ctr, size_t ctrlen)
536
if (!fips_is_operational ())
537
return gpg_error (fips_not_operational ());
539
return _gcry_cipher_setctr (hd, ctr, ctrlen);
502
544
gcry_cipher_ctl (gcry_cipher_hd_t h, int cmd, void *buffer, size_t buflen)
546
if (!fips_is_operational ())
547
return gpg_error (fips_not_operational ());
504
549
return _gcry_cipher_ctl (h, cmd, buffer, buflen);
514
559
gcry_cipher_algo_info (int algo, int what, void *buffer, size_t *nbytes)
561
if (!fips_is_operational ())
562
return gpg_error (fips_not_operational ());
516
564
return _gcry_cipher_algo_info (algo, what, buffer, nbytes);
539
587
void *out, size_t outsize,
540
588
const void *in, size_t inlen)
590
if (!fips_is_operational ())
592
/* Make sure that the plaintext will never make it to OUT. */
594
memset (out, 0x42, outsize);
595
return gpg_error (fips_not_operational ());
542
598
return _gcry_cipher_encrypt (h, out, outsize, in, inlen);
547
603
void *out, size_t outsize,
548
604
const void *in, size_t inlen)
606
if (!fips_is_operational ())
607
return gpg_error (fips_not_operational ());
550
609
return _gcry_cipher_decrypt (h, out, outsize, in, inlen);
573
631
gcry_pk_encrypt (gcry_sexp_t *result, gcry_sexp_t data, gcry_sexp_t pkey)
633
if (!fips_is_operational ())
636
return gpg_error (fips_not_operational ());
575
638
return _gcry_pk_encrypt (result, data, pkey);
579
642
gcry_pk_decrypt (gcry_sexp_t *result, gcry_sexp_t data, gcry_sexp_t skey)
644
if (!fips_is_operational ())
647
return gpg_error (fips_not_operational ());
581
649
return _gcry_pk_decrypt (result, data, skey);
585
653
gcry_pk_sign (gcry_sexp_t *result, gcry_sexp_t data, gcry_sexp_t skey)
655
if (!fips_is_operational ())
658
return gpg_error (fips_not_operational ());
587
660
return _gcry_pk_sign (result, data, skey);
591
664
gcry_pk_verify (gcry_sexp_t sigval, gcry_sexp_t data, gcry_sexp_t pkey)
666
if (!fips_is_operational ())
667
return gpg_error (fips_not_operational ());
593
668
return _gcry_pk_verify (sigval, data, pkey);
597
672
gcry_pk_testkey (gcry_sexp_t key)
674
if (!fips_is_operational ())
675
return gpg_error (fips_not_operational ());
599
676
return _gcry_pk_testkey (key);
603
680
gcry_pk_genkey (gcry_sexp_t *r_key, gcry_sexp_t s_parms)
682
if (!fips_is_operational ())
685
return gpg_error (fips_not_operational ());
605
687
return _gcry_pk_genkey (r_key, s_parms);
615
697
gcry_pk_algo_info (int algo, int what, void *buffer, size_t *nbytes)
699
if (!fips_is_operational ())
700
return gpg_error (fips_not_operational ());
617
702
return _gcry_pk_algo_info (algo, what, buffer, nbytes);
633
718
gcry_pk_get_nbits (gcry_sexp_t key)
720
if (!fips_is_operational ())
722
(void)fips_not_operational ();
635
726
return _gcry_pk_get_nbits (key);
639
730
gcry_pk_get_keygrip (gcry_sexp_t key, unsigned char *array)
732
if (!fips_is_operational ())
734
(void)fips_not_operational ();
641
737
return _gcry_pk_get_keygrip (key, array);
651
747
gcry_md_open (gcry_md_hd_t *h, int algo, unsigned int flags)
749
if (!fips_is_operational ())
752
return gpg_error (fips_not_operational ());
653
755
return _gcry_md_open (h, algo, flags);
663
765
gcry_md_enable (gcry_md_hd_t hd, int algo)
767
if (!fips_is_operational ())
768
return gpg_error (fips_not_operational ());
665
769
return _gcry_md_enable (hd, algo);
669
773
gcry_md_copy (gcry_md_hd_t *bhd, gcry_md_hd_t ahd)
775
if (!fips_is_operational ())
778
return gpg_error (fips_not_operational ());
671
780
return _gcry_md_copy (bhd, ahd);
681
790
gcry_md_ctl (gcry_md_hd_t hd, int cmd, void *buffer, size_t buflen)
792
if (!fips_is_operational ())
793
return gpg_error (fips_not_operational ());
683
794
return _gcry_md_ctl (hd, cmd, buffer, buflen);
687
798
gcry_md_write (gcry_md_hd_t hd, const void *buffer, size_t length)
800
if (!fips_is_operational ())
802
(void)fips_not_operational ();
689
805
_gcry_md_write (hd, buffer, length);
699
815
gcry_md_hash_buffer (int algo, void *digest,
700
816
const void *buffer, size_t length)
818
if (!fips_is_operational ())
820
(void)fips_not_operational ();
821
fips_signal_error ("called in non-operational state");
702
823
_gcry_md_hash_buffer (algo, digest, buffer, length);
706
827
gcry_md_get_algo (gcry_md_hd_t hd)
829
if (!fips_is_operational ())
831
(void)fips_not_operational ();
832
fips_signal_error ("used in non-operational state");
708
835
return _gcry_md_get_algo (hd);
718
845
gcry_md_is_enabled (gcry_md_hd_t a, int algo)
847
if (!fips_is_operational ())
849
(void)fips_not_operational ();
720
853
return _gcry_md_is_enabled (a, algo);
730
863
gcry_md_info (gcry_md_hd_t h, int what, void *buffer, size_t *nbytes)
865
if (!fips_is_operational ())
866
return gpg_error (fips_not_operational ());
732
868
return _gcry_md_info (h, what, buffer, nbytes);
754
890
gcry_md_setkey (gcry_md_hd_t hd, const void *key, size_t keylen)
892
if (!fips_is_operational ())
893
return gpg_error (fips_not_operational ());
756
894
return _gcry_md_setkey (hd, key, keylen);
1054
1192
gcry_randomize (void *buffer, size_t length, enum gcry_random_level level)
1194
if (!fips_is_operational ())
1196
(void)fips_not_operational ();
1197
fips_signal_fatal_error ("called in non-operational state");
1056
1200
_gcry_randomize (buffer, length, level);
1060
1204
gcry_random_add_bytes (const void *buffer, size_t length, int quality)
1206
if (!fips_is_operational ())
1207
return gpg_error (fips_not_operational ());
1062
1208
return _gcry_random_add_bytes (buffer, length, quality);
1066
1212
gcry_random_bytes (size_t nbytes, enum gcry_random_level level)
1214
if (!fips_is_operational ())
1216
(void)fips_not_operational ();
1217
fips_signal_fatal_error ("called in non-operational state");
1068
1221
return _gcry_random_bytes (nbytes,level);
1072
1225
gcry_random_bytes_secure (size_t nbytes, enum gcry_random_level level)
1227
if (!fips_is_operational ())
1229
(void)fips_not_operational ();
1230
fips_signal_fatal_error ("called in non-operational state");
1074
1234
return _gcry_random_bytes_secure (nbytes, level);
1085
1245
gcry_create_nonce (void *buffer, size_t length)
1247
if (!fips_is_operational ())
1249
(void)fips_not_operational ();
1250
fips_signal_fatal_error ("called in non-operational state");
1087
1253
_gcry_create_nonce (buffer, length);
1251
1417
gcry_cipher_register (gcry_cipher_spec_t *cipher, int *algorithm_id,
1252
1418
gcry_module_t *module)
1254
return _gcry_cipher_register (cipher, algorithm_id, module);
1420
return _gcry_cipher_register (cipher, NULL, algorithm_id, module);
1264
1430
gcry_pk_register (gcry_pk_spec_t *pubkey, unsigned int *algorithm_id,
1265
1431
gcry_module_t *module)
1267
return _gcry_pk_register (pubkey, algorithm_id, module);
1433
return _gcry_pk_register (pubkey, NULL, algorithm_id, module);
1277
1443
gcry_md_register (gcry_md_spec_t *digest, unsigned int *algorithm_id,
1278
1444
gcry_module_t *module)
1280
return _gcry_md_register (digest, algorithm_id, module);
1446
return _gcry_md_register (digest, NULL, algorithm_id, module);