Browse Source

z/OS support: AES128 & AES256

Introducing cipher feedback mode so that AES128 and AES256 become
usable as ciphers.
master
David Lanzendörfer 11 months ago
parent
commit
b4d3c8494c
1 changed files with 44 additions and 5 deletions
  1. +44
    -5
      src/symmetric_gskssl.c

+ 44
- 5
src/symmetric_gskssl.c View File

@ -190,12 +190,51 @@ cryptoki_block_decrypt(pgp_crypt_t *crypt, void *out, const void *in)
cryptoki_finish_int( crypt );
}
/*
* The input and output encrypted as though 128bit cfb mode is being used.
* The extra state information to record how much of the 128bit block we have
* used is contained in *num;
*/
void cryptoki_cfb128_encrypt( pgp_crypt_t *crypt, void *out, const void *in, size_t count )
{
uint8_t c;
register int i, n;
for ( i = 0, n = crypt->num; i < count; i++, n = (n + 1) % 16 ) {
if( n == 0 ) {
cfb64_encrypt_iv( crypt );
}
c = (((uint8_t *)in)[i]) ^ (crypt->iv[n]);
((uint8_t *)out)[i] = c;
crypt->iv[n] = c;
}
crypt->num = n;
}
void cryptoki_cfb128_decrypt( pgp_crypt_t *crypt, void *out, const void *in, size_t count )
{
uint8_t c, cc;
register int i, n;
for ( i = 0, n = crypt->num; i < count; i++, n = (n + 1) % 16 ) {
if( n == 0 ) {
cfb64_encrypt_iv( crypt );
}
c = crypt->iv[n];
cc = ((uint8_t *)in)[i];
crypt->iv[n] = cc;
((uint8_t *)out)[i] = c ^ cc;
}
crypt->num = n;
}
/*
* The input and output encrypted as though 64bit cfb mode is being used.
* The extra state information to record how much of the 64bit block we have
* used is contained in *num;
*/
void cryptoki_cfb64_encrypt( pgp_crypt_t *crypt, void *out, const void *in, size_t count)
{
uint8_t c;
@ -307,8 +346,8 @@ static const pgp_crypt_t aes128 =
std_resync,
cryptoki_block_encrypt,
cryptoki_block_decrypt,
cryptoki_cfb64_encrypt,
cryptoki_cfb64_decrypt,
cryptoki_cfb128_encrypt,
cryptoki_cfb128_decrypt,
cryptoki_finish,
TRAILER
};
@ -336,8 +375,8 @@ static const pgp_crypt_t aes256 =
std_resync,
cryptoki_block_encrypt,
cryptoki_block_decrypt,
cryptoki_cfb64_encrypt,
cryptoki_cfb64_decrypt,
cryptoki_cfb128_encrypt,
cryptoki_cfb128_decrypt,
cryptoki_finish,
TRAILER
};


Loading…
Cancel
Save