Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ISC Open Source Projects
BIND
Commits
54c26ab2
Commit
54c26ab2
authored
Feb 05, 1999
by
Mark Andrews
Browse files
dns_cert_{to,from}text()
dns_secalg_{to,from}text()
parent
2e511564
Changes
7
Hide whitespace changes
Inline
Side-by-side
lib/dns/include/dns/cert.h
0 → 100644
View file @
54c26ab2
/*
* Copyright (C) 1999 Internet Software Consortium.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
* CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
* SOFTWARE.
*/
#ifndef DNS_CERT_H
#define DNS_CERT_H 1
#include
<dns/types.h>
dns_result_t
dns_cert_fromtext
(
dns_cert_t
*
certp
,
isc_textregion_t
*
source
);
/*
* Convert the text 'source' refers to into a certificate type.
*
* Requires:
* 'certp' is a valid pointer.
*
* 'source' is a valid text region.
*
* Returns:
* DNS_R_SUCCESS on success
* DNS_R_UNKNOWN type is unknown
*/
dns_result_t
dns_cert_totext
(
dns_cert_t
cert
,
isc_buffer_t
*
target
);
/*
* Put a textual representation of certificate type 'cert' into 'target'.
*
* Requires:
* 'cert' is a valid cert.
*
* 'target' is a valid text buffer.
*
* Ensures:
* If the result is success:
* The used space in 'target' is updated.
*
* Returns:
* DNS_R_SUCCESS on success
* DNS_R_NOSPACE target buffer is too small
*/
#endif
/* DNS_CERT_H */
lib/dns/include/dns/rcode.h
View file @
54c26ab2
/*
* Copyright (C) 199
8, 1999
Internet Software Consortium.
* Copyright (C) 199
9
Internet Software Consortium.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
...
...
lib/dns/include/dns/secalg.h
0 → 100644
View file @
54c26ab2
/*
* Copyright (C) 1999 Internet Software Consortium.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
* CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
* SOFTWARE.
*/
#ifndef DNS_SECALG_H
#define DNS_SECALG_H 1
#include
<dns/types.h>
dns_result_t
dns_secalg_fromtext
(
dns_secalg_t
*
secalgp
,
isc_textregion_t
*
source
);
/*
* Convert the text 'source' refers to into a DNSSEC security algorithm value.
*
* Requires:
* 'secalgp' is a valid pointer.
*
* 'source' is a valid text region.
*
* Returns:
* DNS_R_SUCCESS on success
* DNS_R_UNKNOWN type is unknown
*/
dns_result_t
dns_secalg_totext
(
dns_secalg_t
secalg
,
isc_buffer_t
*
target
);
/*
* Put a textual representation of the DNSSEC security algorithm 'secalg'
* into 'target'.
*
* Requires:
* 'secalg' is a valid secalg.
*
* 'target' is a valid text buffer.
*
* Ensures:
* If the result is success:
* The used space in 'target' is updated.
*
* Returns:
* DNS_R_SUCCESS on success
* DNS_R_NOSPACE target buffer is too small
*/
#endif
/* DNS_SECALG_H */
lib/dns/include/dns/types.h
View file @
54c26ab2
...
...
@@ -39,8 +39,11 @@ typedef void dns_dbversion_t;
typedef
unsigned
char
dns_offsets_t
[
128
];
typedef
struct
dns_compress
dns_compress_t
;
typedef
struct
dns_decompress
dns_decompress_t
;
typedef
isc_uint8_t
dns_secalg_t
;
typedef
isc_uint16_t
dns_rdataclass_t
;
typedef
isc_uint16_t
dns_rdatatype_t
;
typedef
isc_uint16_t
dns_rcode_t
;
typedef
isc_uint16_t
dns_cert_t
;
typedef
isc_uint32_t
dns_ttl_t
;
typedef
struct
dns_rdata
dns_rdata_t
;
typedef
struct
dns_rdatalist
dns_rdatalist_t
;
...
...
@@ -78,7 +81,7 @@ enum {
/* dns_rdataclass_any = 255 TSIG is class ANY specific */
}
;
typedef
enum
{
enum
{
/* standard rcodes */
dns_rcode_noerror
=
0
,
dns_rcode_formerr
=
1
,
...
...
@@ -96,6 +99,6 @@ typedef enum {
dns_rcode_badkey
=
17
,
dns_rcode_badtime
=
18
,
dns_rcode_badmode
=
19
}
dns_rcode_t
;
};
#endif
/* DNS_TYPES_H */
lib/dns/rdata.c
View file @
54c26ab2
...
...
@@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: rdata.c,v 1.2
5
1999/02/0
4
0
6:38
:4
2
marka Exp $ */
/* $Id: rdata.c,v 1.2
6
1999/02/0
5
0
0:05
:4
4
marka Exp $ */
#include
<config.h>
...
...
@@ -33,6 +33,8 @@
#include
<dns/rdataclass.h>
#include
<dns/rdatatype.h>
#include
<dns/rcode.h>
#include
<dns/cert.h>
#include
<dns/secalg.h>
#define RETERR(x) do { \
dns_result_t __r = (x); \
...
...
@@ -127,13 +129,33 @@ static const char octdigits[] = "01234567";
{ dns_rcode_badmode, "BADMODE", 0}, \
{ 0, NULL, 0 }
#define CERTNAMES \
{ 1, "SKIX", 0}, \
{ 2, "SPKI", 0}, \
{ 3, "PGP", 0}, \
{ 253, "URI", 0}, \
{ 254, "OID", 0}, \
{ 0, NULL, 0}
#define SECALGNAMES \
{ 1, "RSA/MD5", 0}, \
{ 2, "Diffie-Hellman", 0}, \
{ 3, "DSA", 0}, \
{ 4, "Ellyptic-Curve", 0}, \
{ 253, "Private/Domain", 0}, \
{ 254, "Private/OID", 0}, \
{ 0, NULL, 0}
struct
tbl
{
unsigned
int
value
;
char
*
name
;
int
flags
;
}
types
[]
=
{
TYPENAMES
METATYPES
{
0
,
NULL
,
0
}
},
classes
[]
=
{
CLASSNAMES
METACLASSES
{
0
,
NULL
,
0
}
},
rcodes
[]
=
{
RCODENAMES
};
rcodes
[]
=
{
RCODENAMES
},
certs
[]
=
{
CERTNAMES
},
secalgs
[]
=
{
SECALGNAMES
};
/***
*** Initialization
...
...
@@ -469,6 +491,70 @@ dns_rcode_totext(dns_rcode_t rcode, isc_buffer_t *target) {
return
(
str_totext
(
buf
,
target
));
}
dns_result_t
dns_cert_fromtext
(
dns_cert_t
*
certp
,
isc_textregion_t
*
source
)
{
int
i
=
0
;
unsigned
int
n
;
while
(
certs
[
i
].
name
!=
NULL
)
{
n
=
strlen
(
certs
[
i
].
name
);
if
(
n
==
source
->
length
&&
strncasecmp
(
source
->
base
,
certs
[
i
].
name
,
n
)
==
0
)
{
*
certp
=
certs
[
i
].
value
;
return
(
DNS_R_SUCCESS
);
}
i
++
;
}
return
(
DNS_R_UNKNOWN
);
}
dns_result_t
dns_cert_totext
(
dns_cert_t
cert
,
isc_buffer_t
*
target
)
{
int
i
=
0
;
char
buf
[
sizeof
"65000"
];
while
(
certs
[
i
].
name
!=
NULL
)
{
if
(
certs
[
i
].
value
==
cert
)
{
return
(
str_totext
(
certs
[
i
].
name
,
target
));
}
i
++
;
}
sprintf
(
buf
,
"%u"
,
cert
);
return
(
str_totext
(
buf
,
target
));
}
dns_result_t
dns_secalg_fromtext
(
dns_secalg_t
*
secalgp
,
isc_textregion_t
*
source
)
{
int
i
=
0
;
unsigned
int
n
;
while
(
secalgs
[
i
].
name
!=
NULL
)
{
n
=
strlen
(
secalgs
[
i
].
name
);
if
(
n
==
source
->
length
&&
strncasecmp
(
source
->
base
,
secalgs
[
i
].
name
,
n
)
==
0
)
{
*
secalgp
=
secalgs
[
i
].
value
;
return
(
DNS_R_SUCCESS
);
}
i
++
;
}
return
(
DNS_R_UNKNOWN
);
}
dns_result_t
dns_secalg_totext
(
dns_secalg_t
secalg
,
isc_buffer_t
*
target
)
{
int
i
=
0
;
char
buf
[
sizeof
"65000"
];
while
(
secalgs
[
i
].
name
!=
NULL
)
{
if
(
secalgs
[
i
].
value
==
secalg
)
{
return
(
str_totext
(
secalgs
[
i
].
name
,
target
));
}
i
++
;
}
sprintf
(
buf
,
"%u"
,
secalg
);
return
(
str_totext
(
buf
,
target
));
}
/* Private function */
static
unsigned
int
...
...
lib/dns/rdata/generic/cert_37.c
View file @
54c26ab2
...
...
@@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: cert_37.c,v 1.
3
1999/02/0
4
00:0
3:29
marka Exp $ */
/* $Id: cert_37.c,v 1.
4
1999/02/0
5
00:0
5:46
marka Exp $ */
/* draft-ietf-dnssec-certs-04.txt */
...
...
@@ -29,8 +29,9 @@ fromtext_cert(dns_rdataclass_t class, dns_rdatatype_t type,
{
isc_token_t
token
;
long
n
;
u
ns
igned
char
c
;
d
ns
_secalg_t
secalg
;
char
*
e
;
dns_cert_t
cert
;
REQUIRE
(
type
==
37
);
...
...
@@ -42,13 +43,13 @@ fromtext_cert(dns_rdataclass_t class, dns_rdatatype_t type,
RETERR
(
gettoken
(
lexer
,
&
token
,
isc_tokentype_string
,
ISC_FALSE
));
n
=
strtol
(
token
.
value
.
as_pointer
,
&
e
,
10
);
if
(
*
e
!=
0
)
{
return
(
DNS_R_NOTIMPLEMENTED
);
RETERR
(
dns_cert_fromtext
(
&
cert
,
&
token
.
value
.
as_textregion
)
);
}
else
{
if
(
n
<
0
||
n
>
0xffff
)
return
(
DNS_R_RANGE
);
c
=
n
;
c
ert
=
n
;
}
RETERR
(
uint16_tobuffer
(
n
,
target
));
RETERR
(
uint16_tobuffer
(
cert
,
target
));
/* key tag */
RETERR
(
gettoken
(
lexer
,
&
token
,
isc_tokentype_number
,
ISC_FALSE
));
...
...
@@ -60,13 +61,13 @@ fromtext_cert(dns_rdataclass_t class, dns_rdatatype_t type,
RETERR
(
gettoken
(
lexer
,
&
token
,
isc_tokentype_string
,
ISC_FALSE
));
n
=
strtol
(
token
.
value
.
as_pointer
,
&
e
,
10
);
if
(
*
e
!=
0
)
{
return
(
DNS_R_NOTIMPLEMENTED
);
RETERR
(
dns_secalg_fromtext
(
&
secalg
,
&
token
.
value
.
as_textregion
)
);
}
else
{
if
(
n
<
0
||
n
>
0xff
)
return
(
DNS_R_RANGE
);
c
=
n
;
secalg
=
n
;
}
RETERR
(
mem_tobuffer
(
target
,
&
c
,
1
));
RETERR
(
mem_tobuffer
(
target
,
&
secalg
,
1
));
return
(
base64_tobuffer
(
lexer
,
target
,
-
1
));
}
...
...
@@ -86,8 +87,7 @@ totext_cert(dns_rdata_t *rdata, dns_name_t *origin, isc_buffer_t *target) {
/* type */
n
=
uint16_fromregion
(
&
sr
);
isc_region_consume
(
&
sr
,
2
);
sprintf
(
buf
,
"%u"
,
n
);
RETERR
(
str_totext
(
buf
,
target
));
RETERR
(
dns_cert_totext
(
n
,
target
));
RETERR
(
str_totext
(
" "
,
target
));
/* key tag */
...
...
@@ -98,10 +98,9 @@ totext_cert(dns_rdata_t *rdata, dns_name_t *origin, isc_buffer_t *target) {
RETERR
(
str_totext
(
" "
,
target
));
/* algorithm */
sprintf
(
buf
,
"%u"
,
sr
.
base
[
0
]);
isc_region_consume
(
&
sr
,
1
);
RETERR
(
str_totext
(
buf
,
target
));
RETERR
(
dns_secalg_totext
(
sr
.
base
[
0
],
target
));
RETERR
(
str_totext
(
" "
,
target
));
isc_region_consume
(
&
sr
,
1
);
/* cert */
return
(
base64_totext
(
&
sr
,
target
));
...
...
lib/dns/rdata/generic/cert_37.h
View file @
54c26ab2
...
...
@@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: cert_37.h,v 1.
3
1999/02/0
4
00:0
3:29
marka Exp $ */
/* $Id: cert_37.h,v 1.
4
1999/02/0
5
00:0
5:46
marka Exp $ */
/* draft-ietf-dnssec-certs-04.txt */
...
...
@@ -29,8 +29,9 @@ fromtext_cert(dns_rdataclass_t class, dns_rdatatype_t type,
{
isc_token_t
token
;
long
n
;
u
ns
igned
char
c
;
d
ns
_secalg_t
secalg
;
char
*
e
;
dns_cert_t
cert
;
REQUIRE
(
type
==
37
);
...
...
@@ -42,13 +43,13 @@ fromtext_cert(dns_rdataclass_t class, dns_rdatatype_t type,
RETERR
(
gettoken
(
lexer
,
&
token
,
isc_tokentype_string
,
ISC_FALSE
));
n
=
strtol
(
token
.
value
.
as_pointer
,
&
e
,
10
);
if
(
*
e
!=
0
)
{
return
(
DNS_R_NOTIMPLEMENTED
);
RETERR
(
dns_cert_fromtext
(
&
cert
,
&
token
.
value
.
as_textregion
)
);
}
else
{
if
(
n
<
0
||
n
>
0xffff
)
return
(
DNS_R_RANGE
);
c
=
n
;
c
ert
=
n
;
}
RETERR
(
uint16_tobuffer
(
n
,
target
));
RETERR
(
uint16_tobuffer
(
cert
,
target
));
/* key tag */
RETERR
(
gettoken
(
lexer
,
&
token
,
isc_tokentype_number
,
ISC_FALSE
));
...
...
@@ -60,13 +61,13 @@ fromtext_cert(dns_rdataclass_t class, dns_rdatatype_t type,
RETERR
(
gettoken
(
lexer
,
&
token
,
isc_tokentype_string
,
ISC_FALSE
));
n
=
strtol
(
token
.
value
.
as_pointer
,
&
e
,
10
);
if
(
*
e
!=
0
)
{
return
(
DNS_R_NOTIMPLEMENTED
);
RETERR
(
dns_secalg_fromtext
(
&
secalg
,
&
token
.
value
.
as_textregion
)
);
}
else
{
if
(
n
<
0
||
n
>
0xff
)
return
(
DNS_R_RANGE
);
c
=
n
;
secalg
=
n
;
}
RETERR
(
mem_tobuffer
(
target
,
&
c
,
1
));
RETERR
(
mem_tobuffer
(
target
,
&
secalg
,
1
));
return
(
base64_tobuffer
(
lexer
,
target
,
-
1
));
}
...
...
@@ -86,8 +87,7 @@ totext_cert(dns_rdata_t *rdata, dns_name_t *origin, isc_buffer_t *target) {
/* type */
n
=
uint16_fromregion
(
&
sr
);
isc_region_consume
(
&
sr
,
2
);
sprintf
(
buf
,
"%u"
,
n
);
RETERR
(
str_totext
(
buf
,
target
));
RETERR
(
dns_cert_totext
(
n
,
target
));
RETERR
(
str_totext
(
" "
,
target
));
/* key tag */
...
...
@@ -98,10 +98,9 @@ totext_cert(dns_rdata_t *rdata, dns_name_t *origin, isc_buffer_t *target) {
RETERR
(
str_totext
(
" "
,
target
));
/* algorithm */
sprintf
(
buf
,
"%u"
,
sr
.
base
[
0
]);
isc_region_consume
(
&
sr
,
1
);
RETERR
(
str_totext
(
buf
,
target
));
RETERR
(
dns_secalg_totext
(
sr
.
base
[
0
],
target
));
RETERR
(
str_totext
(
" "
,
target
));
isc_region_consume
(
&
sr
,
1
);
/* cert */
return
(
base64_totext
(
&
sr
,
target
));
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment