mirror of
https://github.com/strongswan/strongswan.git
synced 2025-10-08 00:02:03 -04:00
encrypted_payload: Encrypted payload can be constructed from plaintext
This commit is contained in:
parent
1e0d8f3ec0
commit
edfd33455c
@ -585,6 +585,16 @@ METHOD(encrypted_payload_t, decrypt, status_t,
|
|||||||
return parse(this, plain);
|
return parse(this, plain);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
METHOD(encrypted_payload_t, decrypt_plain, status_t,
|
||||||
|
private_encrypted_payload_t *this, chunk_t assoc)
|
||||||
|
{
|
||||||
|
if (!this->encrypted.ptr)
|
||||||
|
{
|
||||||
|
return FAILED;
|
||||||
|
}
|
||||||
|
return parse(this, this->encrypted);
|
||||||
|
}
|
||||||
|
|
||||||
METHOD(encrypted_payload_t, decrypt_v1, status_t,
|
METHOD(encrypted_payload_t, decrypt_v1, status_t,
|
||||||
private_encrypted_payload_t *this, chunk_t iv)
|
private_encrypted_payload_t *this, chunk_t iv)
|
||||||
{
|
{
|
||||||
@ -671,3 +681,20 @@ encrypted_payload_t *encrypted_payload_create(payload_type_t type)
|
|||||||
|
|
||||||
return &this->public;
|
return &this->public;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Described in header
|
||||||
|
*/
|
||||||
|
encrypted_payload_t *encrypted_payload_create_from_plain(payload_type_t next,
|
||||||
|
chunk_t plain)
|
||||||
|
{
|
||||||
|
private_encrypted_payload_t *this;
|
||||||
|
|
||||||
|
this = (private_encrypted_payload_t*)encrypted_payload_create(PLV2_ENCRYPTED);
|
||||||
|
this->public.decrypt = _decrypt_plain;
|
||||||
|
this->next_payload = next;
|
||||||
|
this->encrypted = plain;
|
||||||
|
compute_length(this);
|
||||||
|
|
||||||
|
return &this->public;
|
||||||
|
}
|
||||||
|
@ -118,4 +118,15 @@ struct encrypted_payload_t {
|
|||||||
*/
|
*/
|
||||||
encrypted_payload_t *encrypted_payload_create(payload_type_t type);
|
encrypted_payload_t *encrypted_payload_create(payload_type_t type);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates an encrypted payload with the given plain text data and next payload
|
||||||
|
* type.
|
||||||
|
*
|
||||||
|
* @param next next payload type
|
||||||
|
* @param plain plaintext data (gets adopted)
|
||||||
|
* @return encrypted_payload_t object
|
||||||
|
*/
|
||||||
|
encrypted_payload_t *encrypted_payload_create_from_plain(payload_type_t next,
|
||||||
|
chunk_t plain);
|
||||||
|
|
||||||
#endif /** ENCRYPTED_PAYLOAD_H_ @}*/
|
#endif /** ENCRYPTED_PAYLOAD_H_ @}*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user