Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
P
Practical-Cryptdb
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Zhaozhen
Practical-Cryptdb
Commits
a260b621
Commit
a260b621
authored
Jan 11, 2018
by
yiwenshao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove bug in the class onion_conf
parent
4e7dca04
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
156 additions
and
1 deletion
+156
-1
onions.cc
util/onions.cc
+121
-0
onions.hh
util/onions.hh
+35
-1
No files found.
util/onions.cc
View file @
a260b621
#include "util/onions.hh"
const
char
*
const
dir
=
(
char
*
)
"/home/casualet/github/Practical-Cryptdb/conf/CURRENT.conf"
;
std
::
map
<
std
::
string
,
onion
>
string_to_onion
{
{
"oDET"
,
oDET
},
...
...
@@ -24,3 +26,122 @@ std::map<std::string,SECLEVEL> string_to_seclevel={
{
"ASHE"
,
SECLEVEL
::
ASHE
},
{
"RND"
,
SECLEVEL
::
RND
}
};
std
::
vector
<
std
::
string
>
onion_conf
::
parseline
(
std
::
string
temp
){
int
start
=
0
;
int
next
=
0
;
std
::
vector
<
std
::
string
>
res
;
while
(
1
){
char
b
=
temp
.
back
();
if
(
b
==
' '
||
b
==
'\n'
)
temp
.
pop_back
();
else
break
;
}
while
((
next
=
temp
.
find
(
' '
,
start
))
!=-
1
){
res
.
push_back
(
temp
.
substr
(
start
,
next
-
start
));
start
=
next
+
1
;
}
res
.
push_back
(
temp
.
substr
(
start
,
next
-
start
));
return
res
;
}
void
onion_conf
::
read_onionlayout_num
(
std
::
string
temp
){
std
::
vector
<
std
::
string
>
res
=
parseline
(
temp
);
unsigned
int
i
=
1
;
assert
(
res
.
size
()
>
1
);
res
[
0
].
pop_back
();
std
::
string
onion_name
=
res
[
0
];
onions_for_num
[
onion_name
]
=
std
::
vector
<
std
::
string
>
();
for
(;
i
<
res
.
size
();
i
++
){
onions_for_num
[
onion_name
].
push_back
(
res
[
i
]);
}
}
void
onion_conf
::
read_onionlayout_str
(
std
::
string
temp
){
std
::
vector
<
std
::
string
>
res
=
parseline
(
temp
);
unsigned
int
i
=
1
;
assert
(
res
.
size
()
>
1
);
res
[
0
].
pop_back
();
std
::
string
onion_name
=
res
[
0
];
onions_for_str
[
onion_name
]
=
std
::
vector
<
std
::
string
>
();
for
(;
i
<
res
.
size
();
i
++
){
onions_for_str
[
onion_name
].
push_back
(
res
[
i
]);
}
}
onion_conf
::
onion_conf
(
const
char
*
f
=
(
char
*
)
"onionlayout.conf"
){
file
=
fopen
(
f
,
"r"
);
if
(
file
==
NULL
)
{
printf
(
"error
\n
"
);
}
buf
=
(
char
*
)
malloc
(
sizeof
(
char
)
*
100
);
std
::
string
current_onion
=
"null"
;
size_t
n
;
while
(
getline
(
&
buf
,
&
n
,
file
)
!=-
1
){
std
::
string
temp
(
buf
);
if
(
temp
.
size
()
==
0
||
temp
[
0
]
==
'#'
||
temp
[
0
]
==
'\n'
){
continue
;
}
if
(
temp
.
back
()
==
'\n'
)
temp
.
pop_back
();
if
(
temp
==
std
::
string
(
"[onions for num]"
)){
current_onion
=
"num"
;
continue
;
}
else
if
(
temp
==
std
::
string
(
"[onions for str]"
)){
current_onion
=
"str"
;
continue
;
}
else
if
(
temp
==
std
::
string
(
"[end]"
)){
current_onion
=
"null"
;
continue
;
}
assert
(
temp
.
back
()
!=
' '
);
if
(
current_onion
==
std
::
string
(
"num"
)){
read_onionlayout_num
(
temp
);
}
else
if
(
current_onion
==
std
::
string
(
"str"
)){
read_onionlayout_str
(
temp
);
}
else
{
std
::
cout
<<
"error status:"
<<
current_onion
<<
std
::
endl
;
return
;
}
}
from_string_to_onionlayout
();
fclose
(
file
);
free
(
buf
);
}
void
onion_conf
::
from_string_to_onionlayout
(){
for
(
auto
onion_levels
:
onions_for_num
){
std
::
string
onion_name
=
onion_levels
.
first
;
assert
(
string_to_onion
.
find
(
onion_name
)
!=
string_to_onion
.
end
());
onion
o
=
string_to_onion
[
onion_name
];
onionlayout_for_num
[
o
]
=
std
::
vector
<
SECLEVEL
>
();
for
(
auto
item
:
onion_levels
.
second
){
assert
(
string_to_seclevel
.
find
(
item
)
!=
string_to_seclevel
.
end
());
SECLEVEL
l
=
string_to_seclevel
[
item
];
onionlayout_for_num
[
o
].
push_back
(
l
);
}
}
for
(
auto
onion_levels
:
onions_for_str
){
std
::
string
onion_name
=
onion_levels
.
first
;
assert
(
string_to_onion
.
find
(
onion_name
)
!=
string_to_onion
.
end
());
onion
o
=
string_to_onion
[
onion_name
];
onionlayout_for_str
[
o
]
=
std
::
vector
<
SECLEVEL
>
();
for
(
auto
item
:
onion_levels
.
second
){
assert
(
string_to_seclevel
.
find
(
item
)
!=
string_to_seclevel
.
end
());
SECLEVEL
l
=
string_to_seclevel
[
item
];
onionlayout_for_str
[
o
].
push_back
(
l
);
}
}
}
onion_conf
::~
onion_conf
(){
}
util/onions.hh
View file @
a260b621
...
...
@@ -2,11 +2,14 @@
#include <string>
#include <map>
#include <vector>
#include <stdio.h>
#include <list>
#include <iostream>
#include <vector>
#include <assert.h>
extern
const
char
*
const
dir
;
typedef
enum
onion
{
oDET
,
oOPE
,
...
...
@@ -155,3 +158,34 @@ static onionlayout BEST_EFFORT_STR_ONION_LAYOUT = {
//typedef std::map<onion, SECLEVEL> OnionLevelMap;
enum
class
SECURITY_RATING
{
PLAIN
,
BEST_EFFORT
,
SENSITIVE
};
/*
******************************onion_conf**********************************
*/
class
onion_conf
{
std
::
string
dir
;
FILE
*
file
;
char
*
buf
;
std
::
map
<
std
::
string
,
std
::
vector
<
std
::
string
>>
onions_for_num
;
std
::
map
<
std
::
string
,
std
::
vector
<
std
::
string
>>
onions_for_str
;
onionlayout
onionlayout_for_num
;
onionlayout
onionlayout_for_str
;
std
::
vector
<
std
::
string
>
parseline
(
std
::
string
temp
);
void
read_onionlayout_num
(
std
::
string
temp
);
void
read_onionlayout_str
(
std
::
string
temp
);
void
from_string_to_onionlayout
();
public
:
std
::
map
<
std
::
string
,
std
::
vector
<
std
::
string
>>&
get_onion_levels_num
(){
return
onions_for_num
;}
std
::
map
<
std
::
string
,
std
::
vector
<
std
::
string
>>&
get_onion_levels_str
(){
return
onions_for_str
;}
onionlayout
get_onionlayout_for_num
(){
return
onionlayout_for_num
;}
onionlayout
get_onionlayout_for_str
(){
return
onionlayout_for_str
;}
onion_conf
(
const
char
*
filename
);
~
onion_conf
();
};
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment