Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
D
Dnsmasq
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nanahira
Dnsmasq
Commits
f5adbb90
Commit
f5adbb90
authored
May 02, 2012
by
Giovanni Bajo
Committed by
Simon Kelley
Aug 20, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement digest algorithm support.
parent
32b826e2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
51 additions
and
0 deletions
+51
-0
src/dnssec-crypto.h
src/dnssec-crypto.h
+7
-0
src/dnssec-openssl.c
src/dnssec-openssl.c
+44
-0
No files found.
src/dnssec-crypto.h
View file @
f5adbb90
...
@@ -49,4 +49,11 @@ VerifyAlgCtx* verifyalg_alloc(int algo);
...
@@ -49,4 +49,11 @@ VerifyAlgCtx* verifyalg_alloc(int algo);
void
verifyalg_free
(
VerifyAlgCtx
*
a
);
void
verifyalg_free
(
VerifyAlgCtx
*
a
);
int
verifyalg_algonum
(
VerifyAlgCtx
*
a
);
int
verifyalg_algonum
(
VerifyAlgCtx
*
a
);
/* Functions to calculate the digest of a key */
int
digestalg_supported
(
int
algo
);
int
digestalg_begin
(
int
algo
);
void
digestalg_add_data
(
void
*
data
,
unsigned
len
);
void
digestalg_add_keydata
(
struct
keydata
*
key
,
size_t
len
);
int
digestalg_final
(
struct
keydata
*
digest
);
#endif
/* DNSSEC_CRYPTO_H */
#endif
/* DNSSEC_CRYPTO_H */
src/dnssec-openssl.c
View file @
f5adbb90
...
@@ -281,3 +281,47 @@ int verifyalg_algonum(VerifyAlgCtx *a)
...
@@ -281,3 +281,47 @@ int verifyalg_algonum(VerifyAlgCtx *a)
return
-
1
;
return
-
1
;
return
num
;
return
num
;
}
}
static
EVP_MD_CTX
digctx
;
int
digestalg_supported
(
int
algo
)
{
return
(
algo
==
1
||
algo
==
2
);
}
int
digestalg_begin
(
int
algo
)
{
EVP_MD_CTX_init
(
&
digctx
);
if
(
algo
==
1
)
EVP_DigestInit_ex
(
&
digctx
,
EVP_sha1
(),
NULL
);
else
if
(
algo
==
2
)
EVP_DigestInit_ex
(
&
digctx
,
EVP_sha256
(),
NULL
);
else
return
0
;
return
1
;
}
void
digestalg_add_data
(
void
*
data
,
unsigned
len
)
{
EVP_DigestUpdate
(
&
digctx
,
data
,
len
);
}
void
digestalg_add_keydata
(
struct
keydata
*
key
,
size_t
len
)
{
size_t
cnt
;
unsigned
char
*
p
=
NULL
;
while
(
len
)
{
cnt
=
keydata_walk
(
&
key
,
&
p
,
len
);
EVP_DigestUpdate
(
&
digctx
,
p
,
cnt
);
p
+=
cnt
;
len
-=
cnt
;
}
}
int
digestalg_final
(
struct
keydata
*
expected
)
{
unsigned
char
digest
[
32
];
EVP_DigestFinal
(
&
digctx
,
digest
,
NULL
);
/* FIXME: why EVP_MD_CTX_size() crashes? */
return
(
memcmp
(
digest
,
expected
->
key
,
20
)
==
0
);
}
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