Sese Framework
2.3.0
A cross-platform framework
Loading...
Searching...
No Matches
Crypter.h
Go to the documentation of this file.
1
// Copyright 2024 libsese
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
6
//
7
// http://www.apache.org/licenses/LICENSE-2.0
8
//
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
14
20
21
#pragma once
22
23
#include <
sese/io/InputBuffer.h
>
24
25
namespace
sese::security::evp
{
26
28
class
Crypter
{
29
public
:
30
virtual
~Crypter
() =
default
;
31
38
virtual
int
update
(
void
*out,
int
&out_len,
const
void
*
in
,
int
in_len)
const
noexcept
= 0;
39
44
virtual
int
final
(
void
*out,
int
&out_len)
const
noexcept
= 0;
45
};
46
48
struct
CrypterContext
{
49
using
Ptr
= std::unique_ptr<CrypterContext>;
50
51
io::InputBuffer
key
;
52
io::InputBuffer
vector
;
53
const
void
*
crypter_pointer
{};
54
};
55
57
class
Decrypter
final :
public
Crypter
{
58
public
:
59
explicit
Decrypter
(
const
CrypterContext::Ptr
&crypter_context);
60
61
~Decrypter
()
override
;
62
63
int
update
(
void
*out,
int
&out_len,
const
void
*
in
,
int
in_len)
const
noexcept
override
;
64
65
int
final
(
void
*out,
int
&out_len)
const
noexcept
override
;
66
67
private
:
68
void
*
ctx_
;
69
const
CrypterContext::Ptr
&
crypter_context_
;
70
};
71
73
class
Encrypter
final :
public
Crypter
{
74
public
:
75
explicit
Encrypter
(
const
CrypterContext::Ptr
&crypter_context);
76
77
~Encrypter
()
override
;
78
79
int
update
(
void
*out,
int
&out_len,
const
void
*
in
,
int
in_len)
const
noexcept
override
;
80
81
int
final
(
void
*out,
int
&out_len)
const
noexcept
override
;
82
83
private
:
84
void
*
ctx_
;
85
const
CrypterContext::Ptr
&
crypter_context_
;
86
};
87
88
}
sese
security
evp
Crypter.h
Generated on Tue Jan 7 2025 15:49:06 for Sese Framework by
1.11.0