struct PGP_CFB
{
PX_Cipher *ciph; int block_size; int pos; int block_no; int resync;
uint8 fr[PGP_MAX_BLOCK];
uint8 fre[PGP_MAX_BLOCK];
uint8 encbuf[PGP_MAX_BLOCK];
};
int
pgp_cfb_create(PGP_CFB **ctx_p, int algo, const uint8 *key, int key_len, int resync, uint8 *iv)
{ int res;
PX_Cipher *ciph;
PGP_CFB *ctx;
res = pgp_load_cipher(algo, &ciph); if (res < 0) return res;
res = px_cipher_init(ciph, key, key_len, NULL); if (res < 0)
{
px_cipher_free(ciph); return res;
}
/* *DataprocessingfornormalCFB.(PGP_PKT_SYMENCRYPTED_DATA_MDC)
*/ staticint
mix_encrypt_normal(PGP_CFB *ctx, const uint8 *data, int len, uint8 *dst)
{ int i;
for (i = ctx->pos; i < ctx->pos + len; i++)
*dst++ = ctx->encbuf[i] = ctx->fre[i] ^ (*data++);
ctx->pos += len; return len;
}
staticint
mix_decrypt_normal(PGP_CFB *ctx, const uint8 *data, int len, uint8 *dst)
{ int i;
for (i = ctx->pos; i < ctx->pos + len; i++)
{
ctx->encbuf[i] = *data++;
*dst++ = ctx->fre[i] ^ ctx->encbuf[i];
}
ctx->pos += len; return len;
}
/* *DataprocessingforoldPGPCFBmode.(PGP_PKT_SYMENCRYPTED_DATA) * *Thegoalistohidethehorrorfromtherestofthecode, *thusitsallconcentratedhere.
*/ staticint
mix_encrypt_resync(PGP_CFB *ctx, const uint8 *data, int len, uint8 *dst)
{ int i,
n;
/* block #2 is 2 bytes long */ if (ctx->block_no == 2)
{
n = 2 - ctx->pos; if (len < n)
n = len; for (i = ctx->pos; i < ctx->pos + n; i++)
*dst++ = ctx->encbuf[i] = ctx->fre[i] ^ (*data++);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.