• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /macosx-10.10/OpenSSL098-52/src/fips/rand/

Lines Matching refs:ctx

117 static void fips_rand_prng_reset(FIPS_PRNG_CTX *ctx)
119 ctx->seeded = 0;
120 ctx->keyed = 0;
121 ctx->test_mode = 0;
122 ctx->counter = 0;
123 ctx->second = 0;
124 ctx->error = 0;
125 ctx->vpos = 0;
126 OPENSSL_cleanse(ctx->V, AES_BLOCK_LENGTH);
127 OPENSSL_cleanse(&ctx->ks, sizeof(AES_KEY));
131 static int fips_set_prng_key(FIPS_PRNG_CTX *ctx,
140 AES_set_encrypt_key(key, keylen << 3, &ctx->ks);
143 memcpy(ctx->tmp_key, key, 16);
144 ctx->keyed = 2;
147 ctx->keyed = 1;
148 ctx->seeded = 0;
149 ctx->second = 0;
153 static int fips_set_prng_seed(FIPS_PRNG_CTX *ctx,
157 if (!ctx->keyed)
160 if (ctx->test_mode)
164 memcpy(ctx->V, seed, AES_BLOCK_LENGTH);
165 ctx->seeded = 1;
171 ctx->V[ctx->vpos++] ^= seed[i];
172 if (ctx->vpos == AES_BLOCK_LENGTH)
174 ctx->vpos = 0;
178 if (ctx->keyed == 2)
180 if (!memcmp(ctx->tmp_key, ctx->V, 16))
186 OPENSSL_cleanse(ctx->tmp_key, 16);
187 ctx->keyed = 1;
189 ctx->seeded = 1;
195 static int fips_set_test_mode(FIPS_PRNG_CTX *ctx)
197 if (ctx->keyed)
202 ctx->test_mode = 1;
222 static void fips_get_dt(FIPS_PRNG_CTX *ctx)
229 unsigned char *buf = ctx->DT;
256 buf[8] = (unsigned char) (ctx->counter & 0xff);
257 buf[9] = (unsigned char) ((ctx->counter >> 8) & 0xff);
258 buf[10] = (unsigned char) ((ctx->counter >> 16) & 0xff);
259 buf[11] = (unsigned char) ((ctx->counter >> 24) & 0xff);
261 ctx->counter++;
273 static int fips_rand(FIPS_PRNG_CTX *ctx,
279 if (ctx->error)
284 if (!ctx->keyed)
289 if (!ctx->seeded)
296 if (!ctx->test_mode)
297 fips_get_dt(ctx);
298 AES_encrypt(ctx->DT, I, &ctx->ks);
300 tmp[i] = I[i] ^ ctx->V[i];
301 AES_encrypt(tmp, R, &ctx->ks);
304 AES_encrypt(tmp, ctx->V, &ctx->ks);
306 if (ctx->second)
309 memcpy(ctx->last, R, AES_BLOCK_LENGTH);
310 if (!memcmp(R, ctx->last, AES_BLOCK_LENGTH))
313 ctx->error = 1;
318 memcpy(ctx->last, R, AES_BLOCK_LENGTH);
319 if (!ctx->second)
321 ctx->second = 1;
322 if (!ctx->test_mode)