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
d322de06
Commit
d322de06
authored
Apr 23, 2012
by
Giovanni Bajo
Committed by
Simon Kelley
Aug 20, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Further abstract API of verify crypto.
parent
b98f7715
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
72 additions
and
48 deletions
+72
-48
src/dnssec-crypto.h
src/dnssec-crypto.h
+56
-0
src/dnssec.c
src/dnssec.c
+16
-48
No files found.
src/dnssec-crypto.h
0 → 100644
View file @
d322de06
#ifndef DNSSEC_CRYPTO_H
#define DNSSEC_CRYPTO_H
/*
* vtable for a signature verification algorithm.
*
* Each algorithm verifies that a certain signature over a (possibly non-contigous)
* array of data has been made with the specified key.
*
* Sample of usage:
*
* // First, set the signature we need to check. Notice: data is not copied
* // nor consumed, so the pointer must stay valid.
* alg->set_signature(sig, 16);
*
* // Second, push the data in; data is consumed immediately, so the buffer
* // can be freed or modified.
* alg->begin_data();
* alg->add_data(buf1, 123);
* alg->add_data(buf2, 45);
* alg->add_data(buf3, 678);
* alg->end_data();
*
* // Third, verify if we got the correct key for this signature.
* alg->verify(key1, 16);
* alg->verify(key2, 16);
*/
typedef
struct
{
int
(
*
set_signature
)(
unsigned
char
*
data
,
unsigned
len
);
void
(
*
begin_data
)(
void
);
void
(
*
add_data
)(
void
*
data
,
unsigned
len
);
void
(
*
end_data
)(
void
);
int
(
*
verify
)(
unsigned
char
*
key
,
unsigned
key_len
);
}
VerifyAlg
;
#define DEFINE_VALG(alg) \
void alg ## _set_signature(unsigned char *data, unsigned len); \
void alg ## _begin_data(void); \
void alg ## _add_data(void *data, unsigned len); \
void alg ## _end_data(void); \
int alg ## _verify(unsigned char *key, unsigned key_len) \
/**/
#define VALG_VTABLE(alg) { \
alg ## _set_signature, \
alg ## _begin_data, \
alg ## _add_data, \
alg ## _end_data, \
alg ## _verify \
}
/**/
/* Algorithm 5: RSASHA1 */
DEFINE_VALG
(
rsasha1
);
#endif
/* DNSSEC_CRYPTO_H */
src/dnssec.c
View file @
d322de06
#include "dnsmasq.h"
#include "dnsmasq.h"
#include "dnssec-crypto.h"
#include <assert.h>
#include <assert.h>
#define SERIAL_UNDEF -100
#define SERIAL_UNDEF -100
...
@@ -10,39 +11,6 @@
...
@@ -10,39 +11,6 @@
#define countof(x) (long)(sizeof(x) / sizeof(x[0]))
#define countof(x) (long)(sizeof(x) / sizeof(x[0]))
#define MIN(a,b) ((a) < (b) ? (a) : (b))
#define MIN(a,b) ((a) < (b) ? (a) : (b))
/*
* vtable for a signature verification algorithm.
*
* Each algorithm verifies that a certain signature over a (possibly non-contigous)
* array of data has been made with the specified key.
*
* Sample of usage:
*
* // First, set the signature we need to check. Notice: data is not copied
* // nor consumed, so the pointer must stay valid.
* alg->set_signature(sig, 16);
*
* // Second, push the data in; data is consumed immediately, so the buffer
* // can be freed or modified.
* alg->begin_data();
* alg->add_data(buf1, 123);
* alg->add_data(buf2, 45);
* alg->add_data(buf3, 678);
* alg->end_data();
*
* // Third, verify if we got the correct key for this signature.
* alg->verify(key1, 16);
* alg->verify(key2, 16);
*/
typedef
struct
{
int
(
*
set_signature
)(
unsigned
char
*
data
,
unsigned
len
);
void
(
*
begin_data
)(
void
);
void
(
*
add_data
)(
void
*
data
,
unsigned
len
);
void
(
*
end_data
)(
void
);
int
(
*
verify
)(
unsigned
char
*
key
,
unsigned
key_len
);
}
VerifyAlg
;
/* Updated registry that merges various RFCs:
/* Updated registry that merges various RFCs:
https://www.iana.org/assignments/dns-sec-alg-numbers/dns-sec-alg-numbers.xml */
https://www.iana.org/assignments/dns-sec-alg-numbers/dns-sec-alg-numbers.xml */
static
const
VerifyAlg
valgs
[]
=
static
const
VerifyAlg
valgs
[]
=
...
@@ -52,7 +20,7 @@ static const VerifyAlg valgs[] =
...
@@ -52,7 +20,7 @@ static const VerifyAlg valgs[] =
{
0
,
0
,
0
,
0
,
0
},
/* 2: DH */
{
0
,
0
,
0
,
0
,
0
},
/* 2: DH */
{
0
,
0
,
0
,
0
,
0
},
/* 3: DSA */
{
0
,
0
,
0
,
0
,
0
},
/* 3: DSA */
{
0
,
0
,
0
,
0
,
0
},
/* 4: ECC */
{
0
,
0
,
0
,
0
,
0
},
/* 4: ECC */
{
0
,
0
,
0
,
0
,
0
}
,
/* 5: RSASHA1 */
VALG_VTABLE
(
rsasha1
)
,
/* 5: RSASHA1 */
{
0
,
0
,
0
,
0
,
0
},
/* 6: DSA-NSEC3-SHA1 */
{
0
,
0
,
0
,
0
,
0
},
/* 6: DSA-NSEC3-SHA1 */
{
0
,
0
,
0
,
0
,
0
},
/* 7: RSASHA1-NSEC3-SHA1 */
{
0
,
0
,
0
,
0
,
0
},
/* 7: RSASHA1-NSEC3-SHA1 */
{
0
,
0
,
0
,
0
,
0
},
/* 8: RSASHA256 */
{
0
,
0
,
0
,
0
,
0
},
/* 8: RSASHA256 */
...
...
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