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
0360a524
Commit
0360a524
authored
Apr 27, 2012
by
Giovanni Bajo
Committed by
Simon Kelley
Aug 20, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement RSA verification.
parent
262ac851
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
55 additions
and
1 deletion
+55
-1
src/dnssec-openssl.c
src/dnssec-openssl.c
+55
-1
No files found.
src/dnssec-openssl.c
View file @
0360a524
...
...
@@ -2,6 +2,7 @@
#include "dnsmasq.h"
#include "dnssec-crypto.h"
#include <openssl/evp.h>
#include <openssl/rsa.h>
typedef
struct
VACTX_rsasha1
{
...
...
@@ -90,10 +91,63 @@ static void rsasha256_end_data(VerifyAlgCtx *ctx_)
memcpy
(
ctx
->
digest
,
digest
,
32
);
}
static
int
keydata_to_bn
(
BIGNUM
*
ret
,
struct
keydata
**
key_data
,
unsigned
char
**
p
,
unsigned
len
)
{
size_t
cnt
;
BIGNUM
temp
;
BN_init
(
ret
);
cnt
=
keydata_walk
(
key_data
,
p
,
len
);
BN_bin2bn
(
*
p
,
cnt
,
ret
);
len
-=
cnt
;
*
p
+=
cnt
;
while
(
len
>
0
)
{
if
(
!
(
cnt
=
keydata_walk
(
key_data
,
p
,
len
)))
return
0
;
BN_lshift
(
ret
,
ret
,
cnt
*
8
);
BN_init
(
&
temp
);
BN_bin2bn
(
*
p
,
cnt
,
&
temp
);
BN_add
(
ret
,
ret
,
&
temp
);
len
-=
cnt
;
*
p
+=
cnt
;
}
return
1
;
}
static
int
rsasha1_parse_key
(
BIGNUM
*
exp
,
BIGNUM
*
mod
,
struct
keydata
*
key_data
,
unsigned
key_len
)
{
unsigned
char
*
p
=
key_data
->
key
;
size_t
exp_len
,
mod_len
;
CHECKED_GETCHAR
(
exp_len
,
p
,
key_len
);
if
(
exp_len
==
0
)
CHECKED_GETSHORT
(
exp_len
,
p
,
key_len
);
if
(
exp_len
>=
key_len
)
return
0
;
mod_len
=
key_len
-
exp_len
;
return
keydata_to_bn
(
exp
,
&
key_data
,
&
p
,
exp_len
)
&&
keydata_to_bn
(
mod
,
&
key_data
,
&
p
,
mod_len
);
}
static
int
rsasha1_verify
(
VerifyAlgCtx
*
ctx_
,
struct
keydata
*
key_data
,
unsigned
key_len
)
{
VACTX_rsasha1
*
ctx
=
(
VACTX_rsasha1
*
)
ctx_
;
return
0
;
int
validated
=
0
;
printf
(
"OpenSSL RSA verification
\n
"
);
RSA
*
rsa
=
RSA_new
();
rsa
->
e
=
BN_new
();
rsa
->
n
=
BN_new
();
if
(
rsasha1_parse_key
(
rsa
->
e
,
rsa
->
n
,
key_data
,
key_len
)
&&
RSA_verify
(
NID_sha1
,
ctx
->
digest
,
20
,
ctx
->
sig
,
ctx
->
siglen
,
rsa
))
validated
=
1
;
RSA_free
(
rsa
);
return
validated
;
}
static
int
rsasha256_verify
(
VerifyAlgCtx
*
ctx_
,
struct
keydata
*
key
,
unsigned
key_len
)
...
...
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