Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
libdap-crypto
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
cor
libdap-crypto
Commits
524bb296
Commit
524bb296
authored
5 years ago
by
alexander.lysikov
Browse files
Options
Downloads
Patches
Plain Diff
added dap_cert_get_folder()
parent
1688d692
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
include/dap_cert.h
+1
-0
1 addition, 0 deletions
include/dap_cert.h
include/dap_hash.h
+7
-6
7 additions, 6 deletions
include/dap_hash.h
src/dap_cert.c
+34
-1
34 additions, 1 deletion
src/dap_cert.c
with
42 additions
and
7 deletions
include/dap_cert.h
+
1
−
0
View file @
524bb296
...
...
@@ -59,6 +59,7 @@ dap_cert_t * dap_cert_generate_mem(const char * a_cert_name, dap_enc_key_type_t
dap_cert_t
*
dap_cert_add_file
(
const
char
*
a_cert_name
,
const
char
*
a_folder_path
);
int
dap_cert_save_to_folder
(
dap_cert_t
*
a_cert
,
const
char
*
a_file_dir_path
);
const
char
*
dap_cert_get_folder
(
int
a_n_folder_path
);
void
dap_cert_add_folder
(
const
char
*
a_folder_path
);
void
dap_cert_dump
(
dap_cert_t
*
a_cert
);
dap_pkey_t
*
dap_cert_to_pkey
(
dap_cert_t
*
a_cert
);
...
...
This diff is collapsed.
Click to expand it.
include/dap_hash.h
+
7
−
6
View file @
524bb296
...
...
@@ -26,6 +26,7 @@
#include
<stddef.h>
#include
<stdbool.h>
#include
<stdint.h>
#include
<assert.h>
#include
"dap_common.h"
#include
"dap_hash_keccak.h"
...
...
@@ -96,12 +97,12 @@ static inline bool dap_hash_fast_is_blank( dap_chain_hash_fast_t *a_hash )
DAP_STATIC_INLINE
int
dap_chain_hash_fast_to_str
(
dap_chain_hash_fast_t
*
a_hash
,
char
*
a_str
,
size_t
a_str_max
)
{
(
void
)
a_str_max
;
a_str
[
0
]
=
'0'
;
a_str
[
1
]
=
'x'
;
a_str
[
DAP_CHAIN_HASH_FAST_SIZE
*
2
+
2
]
=
0
;
dap_htoa64
(
(
a_str
+
2
),
a_hash
->
raw
,
DAP_CHAIN_HASH_FAST_SIZE
);
return
DAP_CHAIN_HASH_FAST_SIZE
*
2
+
2
;
assert
(
a_str_max
>=
(
DAP_CHAIN_HASH_FAST_SIZE
*
2
+
2
))
;
a_str
[
0
]
=
'0'
;
a_str
[
1
]
=
'x'
;
a_str
[
DAP_CHAIN_HASH_FAST_SIZE
*
2
+
2
]
=
0
;
dap_htoa64
((
a_str
+
2
),
a_hash
->
raw
,
DAP_CHAIN_HASH_FAST_SIZE
);
return
DAP_CHAIN_HASH_FAST_SIZE
*
2
+
2
;
}
static
inline
char
*
dap_chain_hash_fast_to_str_new
(
dap_chain_hash_fast_t
*
a_hash
)
...
...
This diff is collapsed.
Click to expand it.
src/dap_cert.c
+
34
−
1
View file @
524bb296
...
...
@@ -54,6 +54,12 @@ typedef struct dap_cert_item
UT_hash_handle
hh
;
}
dap_cert_item_t
;
typedef
struct
dap_cert_folder
{
char
*
name
;
UT_hash_handle
hh
;
}
dap_cert_folder_t
;
typedef
struct
dap_cert_pvt
{
dap_sign_item_t
*
signs
;
...
...
@@ -63,6 +69,7 @@ typedef struct dap_cert_pvt
#define PVT(a) ( ( dap_cert_pvt_t *)((a)->_pvt) )
static
dap_cert_item_t
*
s_certs
=
NULL
;
static
dap_cert_folder_t
*
s_cert_folders
=
NULL
;
/**
* @brief dap_cert_init
...
...
@@ -444,6 +451,25 @@ void dap_cert_dump(dap_cert_t * a_cert)
printf
(
"Certificates signatures chain size: %lu
\n
"
,
dap_cert_count_cert_sign
(
a_cert
));
}
/**
* @brief dap_cert_get_folder
* @param a_folder_path
*/
const
char
*
dap_cert_get_folder
(
int
a_n_folder_path
)
{
dap_cert_folder_t
*
l_cert_folder_item
=
NULL
,
*
l_cert_folder_item_tmp
=
NULL
;
int
l_n_cur_folder_path
=
0
;
HASH_ITER
(
hh
,
s_cert_folders
,
l_cert_folder_item
,
l_cert_folder_item_tmp
)
{
if
(
l_cert_folder_item
)
{
if
(
a_n_folder_path
==
l_n_cur_folder_path
)
return
l_cert_folder_item
->
name
;
l_n_cur_folder_path
++
;
}
}
return
NULL
;
}
/**
* @brief dap_cert_add_folder
...
...
@@ -451,6 +477,13 @@ void dap_cert_dump(dap_cert_t * a_cert)
*/
void
dap_cert_add_folder
(
const
char
*
a_folder_path
)
{
// save dir
{
dap_cert_folder_t
*
l_cert_folder_item
=
DAP_NEW_Z
(
dap_cert_folder_t
);
l_cert_folder_item
->
name
=
dap_strdup
(
a_folder_path
);
HASH_ADD_STR
(
s_cert_folders
,
name
,
l_cert_folder_item
);
}
DIR
*
l_dir
=
opendir
(
a_folder_path
);
if
(
l_dir
)
{
struct
dirent
*
l_dir_entry
;
...
...
@@ -471,9 +504,9 @@ void dap_cert_add_folder(const char *a_folder_path)
DAP_DELETE
(
l_cert_name
);
}
}
}
closedir
(
l_dir
);
log_it
(
L_NOTICE
,
"Added folder %s"
,
a_folder_path
);
}
else
log_it
(
L_WARNING
,
"Can't add folder %s to cert manager"
,
a_folder_path
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment