|
1 /* |
|
2 * Copyright 2007 SPARTA Inc |
|
3 * |
|
4 * Licensed under the Apache License, Version 2.0 (the "License"); |
|
5 * you may not use this file except in compliance with the License. |
|
6 * You may obtain a copy of the License at |
|
7 * |
|
8 * http://www.apache.org/licenses/LICENSE-2.0 |
|
9 * |
|
10 * Unless required by applicable law or agreed to in writing, software |
|
11 * distributed under the License is distributed on an "AS IS" BASIS, |
|
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
13 * See the License for the specific language governing permissions and |
|
14 * limitations under the License. |
|
15 */ |
|
16 |
|
17 #ifndef _KEYSTEWARD_H_ |
|
18 #define _KEYSTEWARD_H_ |
|
19 |
|
20 #ifdef BSP_ENABLED |
|
21 |
|
22 #include <oasys/util/ScratchBuffer.h> |
|
23 //#include "bundling/BlockProcessor.h" |
|
24 |
|
25 namespace dtn { |
|
26 |
|
27 typedef oasys::ScratchBuffer<u_char*, 64> DataBuffer; |
|
28 |
|
29 class Bundle; |
|
30 |
|
31 class KeyParameterInfo; //opaque info -- hints for what key to use |
|
32 |
|
33 class KeySteward { |
|
34 |
|
35 public: |
|
36 |
|
37 /// static class in this demo code |
|
38 |
|
39 static int encrypt(const Bundle* b, |
|
40 KeyParameterInfo* kpi, |
|
41 const LinkRef& link, |
|
42 std::string security_dest, |
|
43 u_char* data, |
|
44 size_t data_len, |
|
45 DataBuffer& db); |
|
46 |
|
47 static int decrypt(const Bundle* b, |
|
48 std::string security_src, |
|
49 u_char* enc_data, |
|
50 size_t enc_data_len, |
|
51 DataBuffer& db); |
|
52 |
|
53 static int sign(const Bundle* b, |
|
54 KeyParameterInfo*kpi, |
|
55 const LinkRef& link, |
|
56 DataBuffer& db_digest, |
|
57 DataBuffer& db_signed); |
|
58 |
|
59 static int signature_length(const Bundle* b, |
|
60 KeyParameterInfo* kpi, |
|
61 const LinkRef& link, |
|
62 size_t data_len, |
|
63 size_t& out_len); |
|
64 |
|
65 static int verify(const Bundle* b, |
|
66 u_char* enc_data, |
|
67 size_t enc_data_len, |
|
68 u_char* data, |
|
69 size_t data_len); |
|
70 }; |
|
71 |
|
72 |
|
73 } // namespace dtn |
|
74 |
|
75 #endif /* BSP_ENABLED */ |
|
76 |
|
77 #endif /* _KEYSTEWARD_H_ */ |