Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Knot DNS
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
24
Issues
24
List
Boards
Labels
Service Desk
Milestones
Merge Requests
18
Merge Requests
18
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
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
Knot projects
Knot DNS
Commits
e522a1ed
Commit
e522a1ed
authored
Jul 15, 2015
by
Jan Včelák
🚀
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
libdnssec, add tests for dnssec_key_create_ds()
parent
e9127ed8
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
76 additions
and
0 deletions
+76
-0
src/dnssec/tests/.gitignore
src/dnssec/tests/.gitignore
+1
-0
src/dnssec/tests/Makefile.am
src/dnssec/tests/Makefile.am
+1
-0
src/dnssec/tests/key_ds.c
src/dnssec/tests/key_ds.c
+74
-0
No files found.
src/dnssec/tests/.gitignore
View file @
e522a1ed
...
...
@@ -11,6 +11,7 @@
/kasp_store
/key
/key_algorithm
/key_ds
/keyid
/keystore_pkcs8
/keystore_pkcs8_dir
...
...
src/dnssec/tests/Makefile.am
View file @
e522a1ed
...
...
@@ -28,6 +28,7 @@ check_PROGRAMS = \
kasp_store
\
key
\
key_algorithm
\
key_ds
\
keyid
\
keystore_pkcs8
\
keystore_pkcs8_dir
\
...
...
src/dnssec/tests/key_ds.c
0 → 100644
View file @
e522a1ed
/* Copyright (C) 2015 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <tap/basic.h>
#include <stddef.h>
#include <string.h>
#include "dnssec/crypto.h"
#include "dnssec/error.h"
#include "dnssec/key.h"
#include "sample_keys.h"
static
void
test_key
(
const
char
*
name
,
const
struct
key_parameters
*
params
)
{
dnssec_key_t
*
key
=
NULL
;
dnssec_key_new
(
&
key
);
dnssec_key_set_dname
(
key
,
params
->
name
);
dnssec_key_set_rdata
(
key
,
&
params
->
rdata
);
struct
ds_type
{
const
char
*
name
;
dnssec_key_digest_t
digest
;
size_t
params_offset
;
};
static
const
struct
ds_type
DS_TYPES
[]
=
{
{
"SHA-1"
,
DNSSEC_KEY_DIGEST_SHA1
,
offsetof
(
typeof
(
*
params
),
ds_sha1
)
},
{
"SHA-256"
,
DNSSEC_KEY_DIGEST_SHA256
,
offsetof
(
typeof
(
*
params
),
ds_sha256
)
},
{
"SHA-384"
,
DNSSEC_KEY_DIGEST_SHA384
,
offsetof
(
typeof
(
*
params
),
ds_sha384
)
},
{
NULL
}
};
for
(
const
struct
ds_type
*
dt
=
DS_TYPES
;
dt
->
name
!=
NULL
;
dt
++
)
{
dnssec_binary_t
ds
=
{
0
};
int
r
=
dnssec_key_create_ds
(
key
,
dt
->
digest
,
&
ds
);
const
dnssec_binary_t
*
expect
=
(
void
*
)
params
+
dt
->
params_offset
;
ok
(
r
==
DNSSEC_EOK
&&
ds
.
size
==
expect
->
size
&&
memcmp
(
ds
.
data
,
expect
->
data
,
ds
.
size
)
==
0
,
"dnssec_key_create_ds() for %s/%s"
,
name
,
dt
->
name
);
dnssec_binary_free
(
&
ds
);
}
dnssec_key_free
(
key
);
}
int
main
(
int
argc
,
char
*
argv
[])
{
plan_lazy
();
test_key
(
"RSA"
,
&
SAMPLE_RSA_KEY
);
test_key
(
"DSA"
,
&
SAMPLE_DSA_KEY
);
test_key
(
"ECDSA"
,
&
SAMPLE_ECDSA_KEY
);
return
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