Sese Framework
x.y.z
A cross-platform framework
载入中...
搜索中...
未找到
Crypter.h
浏览该文件的文档.
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
;
54
const
void
*
crypter_pointer
{};
55
};
56
58
class
Decrypter
final :
public
Crypter
{
59
public
:
60
explicit
Decrypter
(
const
CrypterContext::Ptr
&crypter_context);
61
62
~Decrypter
()
override
;
63
64
int
update
(
void
*out,
int
&out_len,
const
void
*
in
,
int
in_len)
const
noexcept
override
;
65
66
int
final
(
void
*out,
int
&out_len)
const
noexcept
override
;
67
68
private
:
69
void
*
ctx_
;
70
const
CrypterContext::Ptr
&
crypter_context_
;
71
};
72
74
class
Encrypter
final :
public
Crypter
{
75
public
:
76
explicit
Encrypter
(
const
CrypterContext::Ptr
&crypter_context);
77
78
~Encrypter
()
override
;
79
80
int
update
(
void
*out,
int
&out_len,
const
void
*
in
,
int
in_len)
const
noexcept
override
;
81
82
int
final
(
void
*out,
int
&out_len)
const
noexcept
override
;
83
84
private
:
85
void
*
ctx_
;
86
const
CrypterContext::Ptr
&
crypter_context_
;
87
};
88
89
}
sese
security
evp
Crypter.h
生成于 2024年 十一月 4日 星期一 09:58:02 , 为 Sese Framework使用
1.11.0