1083
1071
memcpy(ctx->iv, iv, sizeof(iv));
1074
static void aes_sdctr(unsigned char *blk, int len, AESContext *ctx)
1076
word32 iv[4], b[4], tmp;
1079
assert((len & 15) == 0);
1081
memcpy(iv, ctx->iv, sizeof(iv));
1084
memcpy(b, iv, sizeof(b));
1085
aes_encrypt(ctx, b);
1086
for (i = 0; i < 4; i++) {
1087
tmp = GET_32BIT_MSB_FIRST(blk + 4 * i);
1088
PUT_32BIT_MSB_FIRST(blk + 4 * i, tmp ^ b[i]);
1090
for (i = 3; i >= 0; i--)
1091
if ((iv[i] = (iv[i] + 1) & 0xffffffff) != 0)
1097
memcpy(ctx->iv, iv, sizeof(iv));
1086
1100
static void *aes_make_context(void)
1088
1102
return snew(AESContext);
1149
1169
memset(&ctx, 0, sizeof(ctx));
1172
static const struct ssh2_cipher ssh_aes128_ctr = {
1173
aes_make_context, aes_free_context, aes_iv, aes128_key,
1174
aes_ssh2_sdctr, aes_ssh2_sdctr,
1176
16, 128, 0, "AES-128 SDCTR"
1179
static const struct ssh2_cipher ssh_aes192_ctr = {
1180
aes_make_context, aes_free_context, aes_iv, aes192_key,
1181
aes_ssh2_sdctr, aes_ssh2_sdctr,
1183
16, 192, 0, "AES-192 SDCTR"
1186
static const struct ssh2_cipher ssh_aes256_ctr = {
1187
aes_make_context, aes_free_context, aes_iv, aes256_key,
1188
aes_ssh2_sdctr, aes_ssh2_sdctr,
1190
16, 256, 0, "AES-256 SDCTR"
1152
1193
static const struct ssh2_cipher ssh_aes128 = {
1153
1194
aes_make_context, aes_free_context, aes_iv, aes128_key,
1154
1195
aes_ssh2_encrypt_blk, aes_ssh2_decrypt_blk,
1197
16, 128, SSH_CIPHER_IS_CBC, "AES-128 CBC"
1159
1200
static const struct ssh2_cipher ssh_aes192 = {
1160
1201
aes_make_context, aes_free_context, aes_iv, aes192_key,
1161
1202
aes_ssh2_encrypt_blk, aes_ssh2_decrypt_blk,
1204
16, 192, SSH_CIPHER_IS_CBC, "AES-192 CBC"
1166
1207
static const struct ssh2_cipher ssh_aes256 = {
1167
1208
aes_make_context, aes_free_context, aes_iv, aes256_key,
1168
1209
aes_ssh2_encrypt_blk, aes_ssh2_decrypt_blk,
1173
static const struct ssh2_cipher ssh_rijndael128 = {
1174
aes_make_context, aes_free_context, aes_iv, aes128_key,
1175
aes_ssh2_encrypt_blk, aes_ssh2_decrypt_blk,
1180
static const struct ssh2_cipher ssh_rijndael192 = {
1181
aes_make_context, aes_free_context, aes_iv, aes192_key,
1182
aes_ssh2_encrypt_blk, aes_ssh2_decrypt_blk,
1187
static const struct ssh2_cipher ssh_rijndael256 = {
1188
aes_make_context, aes_free_context, aes_iv, aes256_key,
1189
aes_ssh2_encrypt_blk, aes_ssh2_decrypt_blk,
1211
16, 256, SSH_CIPHER_IS_CBC, "AES-256 CBC"
1194
1214
static const struct ssh2_cipher ssh_rijndael_lysator = {
1195
1215
aes_make_context, aes_free_context, aes_iv, aes256_key,
1196
1216
aes_ssh2_encrypt_blk, aes_ssh2_decrypt_blk,
1197
1217
"rijndael-cbc@lysator.liu.se",
1218
16, 256, SSH_CIPHER_IS_CBC, "AES-256 CBC"
1201
1221
static const struct ssh2_cipher *const aes_list[] = {
1204
1224
&ssh_rijndael_lysator,
1211
1231
const struct ssh2_ciphers ssh2_aes = {