* Padding can be disabled using yaca_context_set_property() and
* #YACA_PROPERTY_PADDING,#YACA_PADDING_NONE,
* then the total length of data passed until *_finalize() MUST be a multiple of block size.
- * #YACA_PROPERTY_PADDING can be set at the latest before the *_finalize() call.
+ * In case of encrypt/seal #YACA_PROPERTY_PADDING can be set at the
+ * latest before the *_finalize() call. In case of decrypt/open
+ * it can be set at the latest before the *_update() call.
*/
YACA_BCM_ECB,
* Padding can be disabled using yaca_context_set_property() and
* #YACA_PROPERTY_PADDING, #YACA_PADDING_NONE,
* then the total length of data passed until *_finalize() MUST be a multiple of block size.
- * #YACA_PROPERTY_PADDING can be set at the latest before the *_finalize() call.
+ * In case of encrypt/seal #YACA_PROPERTY_PADDING can be set at the
+ * latest before the *_finalize() call. In case of decrypt/open
+ * it can be set at the latest before the *_update() call.
*/
YACA_BCM_CBC,
value_len != sizeof(yaca_padding_e) ||
(*(yaca_padding_e*)value != YACA_PADDING_NONE &&
*(yaca_padding_e*)value != YACA_PADDING_PKCS7) ||
- c->state == ENC_CTX_FINALIZED)
+ ((is_encryption_op(c->op_type)) && c->state == ENC_CTX_FINALIZED) ||
+ (!(is_encryption_op(c->op_type)) && c->state != ENC_CTX_INITIALIZED))
return YACA_ERROR_INVALID_PARAMETER;
int padding = *(yaca_padding_e*)value == YACA_PADDING_NONE ? 0 : 1;