Skip to content

Commit

Permalink
[cipher.c] fix problem with OpenBSD sync
Browse files Browse the repository at this point in the history
  • Loading branch information
Tim Rice committed Mar 22, 2002
1 parent 4435a55 commit f29a653
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 39 deletions.
3 changes: 2 additions & 1 deletion ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
- (stevesk) [defines.h] #define MAP_ANON MAP_ANONYMOUS for HP-UX; other
platforms may need this--I'm not sure. mmap() issues will need to be
addressed further.
- (tim) [cipher.c] fix problem with OpenBSD sync

20020321
- (bal) OpenBSD CVS Sync
Expand Down Expand Up @@ -8004,4 +8005,4 @@
- Wrote replacements for strlcpy and mkdtemp
- Released 1.0pre1

$Id: ChangeLog,v 1.1973 2002/03/22 21:08:03 stevesk Exp $
$Id: ChangeLog,v 1.1974 2002/03/22 21:27:40 tim Exp $
76 changes: 38 additions & 38 deletions cipher.c
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,44 @@ ssh_rijndael_cbc(EVP_CIPHER_CTX *ctx, u_char *dest, const u_char *src,
for (i = blocks; i > 0; i--, cnow-=RIJNDAEL_BLOCKSIZE,
plain-=RIJNDAEL_BLOCKSIZE) {
rijndael_decrypt(&c->r_ctx, cnow, plain);
ivp = (i == 1) ? c->r_iv : cnow-RIJNDAEL_BLOCKSIZE;
for (j = 0; j < RIJNDAEL_BLOCKSIZE; j++)
plain[j] ^= ivp[j];
}
memcpy(c->r_iv, buf, RIJNDAEL_BLOCKSIZE);
}
return (1);
}
static int
ssh_rijndael_cleanup(EVP_CIPHER_CTX *ctx)
{
struct ssh_rijndael_ctx *c;

if ((c = EVP_CIPHER_CTX_get_app_data(ctx)) != NULL) {
memset(c, 0, sizeof(*c));
xfree(c);
EVP_CIPHER_CTX_set_app_data(ctx, NULL);
}
return (1);
}
static EVP_CIPHER *
evp_rijndael(void)
{
static EVP_CIPHER rijndal_cbc;

memset(&rijndal_cbc, 0, sizeof(EVP_CIPHER));
rijndal_cbc.nid = NID_undef;
rijndal_cbc.block_size = RIJNDAEL_BLOCKSIZE;
rijndal_cbc.iv_len = RIJNDAEL_BLOCKSIZE;
rijndal_cbc.key_len = 16;
rijndal_cbc.init = ssh_rijndael_init;
rijndal_cbc.cleanup = ssh_rijndael_cleanup;
rijndal_cbc.do_cipher = ssh_rijndael_cbc;
#ifndef SSH_OLD_EVP
rijndal_cbc.flags = EVP_CIPH_CBC_MODE | EVP_CIPH_VARIABLE_LENGTH |
EVP_CIPH_ALWAYS_CALL_INIT;
#endif
return (&rijndal_cbc);
}

/*
Expand Down Expand Up @@ -675,42 +713,4 @@ cipher_set_keycontext(CipherContext *cc, u_char *dat)
plen = EVP_X_STATE_LEN(cc->evp);
memcpy(EVP_X_STATE(cc->evp), dat, plen);
}
ivp = (i == 1) ? c->r_iv : cnow-RIJNDAEL_BLOCKSIZE;
for (j = 0; j < RIJNDAEL_BLOCKSIZE; j++)
plain[j] ^= ivp[j];
}
memcpy(c->r_iv, buf, RIJNDAEL_BLOCKSIZE);
}
return (1);
}
static int
ssh_rijndael_cleanup(EVP_CIPHER_CTX *ctx)
{
struct ssh_rijndael_ctx *c;

if ((c = EVP_CIPHER_CTX_get_app_data(ctx)) != NULL) {
memset(c, 0, sizeof(*c));
xfree(c);
EVP_CIPHER_CTX_set_app_data(ctx, NULL);
}
return (1);
}
static EVP_CIPHER *
evp_rijndael(void)
{
static EVP_CIPHER rijndal_cbc;

memset(&rijndal_cbc, 0, sizeof(EVP_CIPHER));
rijndal_cbc.nid = NID_undef;
rijndal_cbc.block_size = RIJNDAEL_BLOCKSIZE;
rijndal_cbc.iv_len = RIJNDAEL_BLOCKSIZE;
rijndal_cbc.key_len = 16;
rijndal_cbc.init = ssh_rijndael_init;
rijndal_cbc.cleanup = ssh_rijndael_cleanup;
rijndal_cbc.do_cipher = ssh_rijndael_cbc;
#ifndef SSH_OLD_EVP
rijndal_cbc.flags = EVP_CIPH_CBC_MODE | EVP_CIPH_VARIABLE_LENGTH |
EVP_CIPH_ALWAYS_CALL_INIT;
#endif
return (&rijndal_cbc);
}

0 comments on commit f29a653

Please sign in to comment.