CC_INLINE size_t ccsiv_ciphertext_size(const struct ccmode_siv *mode,
size_t plaintext_size)
{
- return plaintext_size+mode->cbc->block_size;
+ return plaintext_size + mode->cbc->block_size;
}
CC_INLINE size_t ccsiv_plaintext_size(const struct ccmode_siv *mode,
if (ciphertext_size<mode->cbc->block_size) {
return 0; // error
}
- return ciphertext_size-mode->cbc->block_size;
+ return ciphertext_size - mode->cbc->block_size;
}
-// In theory, supported key sizes are 32, 48, 64 bytes
-// In practice, we only support key size 32 bytes due to cmac limitation
+// Supported key sizes are 32, 48, 64 bytes
CC_INLINE int ccsiv_init(const struct ccmode_siv *mode, ccsiv_ctx *ctx,
size_t key_byte_len, const uint8_t *key)
{
}
// Clear all context for reuse.
-// Key is clear to avoid leaking it
CC_INLINE int ccsiv_reset(const struct ccmode_siv *mode, ccsiv_ctx *ctx)
{
return mode->reset(ctx);
{
int rc;
ccsiv_ctx_decl(mode->size, ctx);
- ccsiv_init(mode, ctx, key_len, key);
+ rc=mode->init(mode, ctx, key_len, key);
+ if (rc) {return rc;}
rc=mode->set_nonce(ctx, nonce_nbytes, nonce);
if (rc) {return rc;}
rc=mode->auth(ctx, adata_nbytes, adata);
return rc;
}
-void ccmode_factory_siv_encrypt(struct ccmode_siv *siv,
- const struct ccmode_cbc *cbc,
- const struct ccmode_ctr *ctr);
-
-void ccmode_factory_siv_decrypt(struct ccmode_siv *siv,
- const struct ccmode_cbc *cbc,
- const struct ccmode_ctr *ctr);
-
-
#endif /* _CORECRYPTO_CCMODE_H_ */