~ubuntu-branches/ubuntu/natty/libgcrypt11/natty-proposed

« back to all changes in this revision

Viewing changes to tests/register.c

  • Committer: Bazaar Package Importer
  • Author(s): Andreas Metzler
  • Date: 2009-02-21 13:46:58 UTC
  • mto: (1.1.6 upstream) (2.1.3 squeeze)
  • mto: This revision was merged to the branch mainline in revision 18.
  • Revision ID: james.westby@ubuntu.com-20090221134658-855twvcr4ezk2ron
ImportĀ upstreamĀ versionĀ 1.4.4

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
#include "../src/gcrypt.h"
31
31
 
32
32
static int verbose;
 
33
static int in_fips_mode;
33
34
 
34
35
static void
35
36
die (const char *format, ...)
114
115
  int ret;
115
116
 
116
117
  err = gcry_cipher_register (&cipher_spec_foo, &algorithm, &module);
117
 
  assert (! err);
 
118
  if (in_fips_mode)
 
119
    {
 
120
      if (gpg_err_code (err) != GPG_ERR_NOT_SUPPORTED)
 
121
        die ("register cipher failed in fips mode: %s\n", gpg_strerror (err));
 
122
      return;
 
123
    }
 
124
  else
 
125
    {
 
126
      if (err)
 
127
        die ("register cipher failed: %s\n", gpg_strerror (err));
 
128
    }
118
129
 
119
130
  err = gcry_cipher_open (&h, algorithm, GCRY_CIPHER_MODE_CBC, 0);
120
 
  assert (! err);
 
131
  if (err)
 
132
    die ("gcry_cipher_open failed: %s\n", gpg_strerror (err));
121
133
 
122
134
  err = gcry_cipher_encrypt (h,
123
135
                             (unsigned char *) encrypted, sizeof (encrypted),
163
175
  if (debug)
164
176
    gcry_control (GCRYCTL_SET_DEBUG_FLAGS, 1u , 0);
165
177
 
 
178
  if ( gcry_control (GCRYCTL_FIPS_MODE_P, 0) )
 
179
    in_fips_mode = 1;
 
180
 
166
181
  for (; i > 0; i--)
167
182
    check_run ();
168
 
  
169
 
  return 0;
 
183
 
 
184
  /* In fips mode we let the Makefile skip this test because a PASS
 
185
     would not make much sense with all egistering disabled. */
 
186
  return in_fips_mode? 77:0; 
170
187
}