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
1d58763c
Commit
1d58763c
authored
May 15, 2000
by
Brian Wellington
Browse files
Added dst_key_parsefilename
parent
70cd89aa
Changes
2
Hide whitespace changes
Inline
Side-by-side
lib/dns/sec/dst/dst_api.c
View file @
1d58763c
...
...
@@ -19,11 +19,13 @@
/*
* Principal Author: Brian Wellington
* $Id: dst_api.c,v 1.3
5
2000/05/15 2
1:02:28
bwelling Exp $
* $Id: dst_api.c,v 1.3
6
2000/05/15 2
3:14:41
bwelling Exp $
*/
#include
<config.h>
#include
<stdlib.h>
#include
<isc/buffer.h>
#include
<isc/dir.h>
#include
<isc/lex.h>
...
...
@@ -773,6 +775,97 @@ dst_key_buildfilename(const dst_key_t *key, const int type, isc_buffer_t *out) {
return
(
ISC_R_SUCCESS
);
}
isc_result_t
dst_key_parsefilename
(
isc_buffer_t
*
source
,
isc_mem_t
*
mctx
,
char
**
name
,
isc_uint16_t
*
id
,
int
*
alg
,
char
**
suffix
)
{
isc_result_t
result
=
ISC_R_SUCCESS
;
char
c
,
str
[
6
],
*
p
,
*
endp
;
isc_region_t
r
;
unsigned
int
length
;
REQUIRE
(
source
!=
NULL
);
REQUIRE
(
mctx
!=
NULL
);
REQUIRE
(
name
!=
NULL
&&
*
name
==
NULL
);
REQUIRE
(
id
!=
NULL
);
REQUIRE
(
alg
!=
NULL
);
REQUIRE
(
suffix
==
NULL
||
*
suffix
==
NULL
);
if
(
isc_buffer_remaininglength
(
source
)
<
1
)
return
(
ISC_R_UNEXPECTEDEND
);
c
=
(
char
)
isc_buffer_getuint8
(
source
);
if
(
c
!=
'K'
)
{
result
=
ISC_R_INVALIDFILE
;
goto
fail
;
}
isc_buffer_remainingregion
(
source
,
&
r
);
p
=
(
char
*
)
r
.
base
;
length
=
r
.
length
;
while
(
length
>
0
&&
*
p
!=
'+'
)
{
length
--
;
p
++
;
}
if
(
length
==
0
)
return
(
ISC_R_UNEXPECTEDEND
);
length
=
p
-
(
char
*
)
r
.
base
;
*
name
=
isc_mem_get
(
mctx
,
length
+
1
);
if
(
*
name
==
NULL
)
return
(
ISC_R_NOMEMORY
);
memcpy
(
*
name
,
r
.
base
,
length
);
(
*
name
)[
length
]
=
0
;
isc_buffer_forward
(
source
,
length
);
if
(
isc_buffer_remaininglength
(
source
)
<
1
+
3
+
1
+
5
)
{
result
=
ISC_R_UNEXPECTEDEND
;
goto
fail
;
}
c
=
(
char
)
isc_buffer_getuint8
(
source
);
if
(
c
!=
'+'
)
{
result
=
ISC_R_INVALIDFILE
;
goto
fail
;
}
isc_buffer_remainingregion
(
source
,
&
r
);
memcpy
(
str
,
r
.
base
,
3
);
str
[
3
]
=
0
;
*
alg
=
strtol
(
str
,
&
endp
,
10
);
if
(
*
endp
!=
'\0'
)
{
result
=
ISC_R_INVALIDFILE
;
goto
fail
;
}
isc_buffer_forward
(
source
,
3
);
c
=
(
char
)
isc_buffer_getuint8
(
source
);
if
(
c
!=
'+'
)
{
result
=
ISC_R_INVALIDFILE
;
goto
fail
;
}
isc_buffer_remainingregion
(
source
,
&
r
);
memcpy
(
str
,
r
.
base
,
5
);
str
[
5
]
=
0
;
*
id
=
strtol
(
str
,
&
endp
,
10
);
if
(
*
endp
!=
'\0'
)
{
result
=
ISC_R_INVALIDFILE
;
goto
fail
;
}
isc_buffer_forward
(
source
,
5
);
if
(
suffix
==
NULL
)
return
(
ISC_R_SUCCESS
);
isc_buffer_remainingregion
(
source
,
&
r
);
*
suffix
=
isc_mem_get
(
mctx
,
r
.
length
+
1
);
if
(
*
suffix
==
NULL
)
{
result
=
ISC_R_NOMEMORY
;
goto
fail
;
}
if
(
r
.
length
>
0
)
memcpy
(
*
suffix
,
r
.
base
,
r
.
length
);
(
*
suffix
)[
r
.
length
]
=
0
;
return
(
ISC_R_SUCCESS
);
fail:
if
(
*
name
!=
NULL
)
isc_mem_put
(
mctx
,
name
,
strlen
(
*
name
)
+
1
);
return
(
result
);
}
/*
* dst_sig_size
* Computes the maximum size of a signature generated by the given key
...
...
lib/dns/sec/dst/include/dst/dst.h
View file @
1d58763c
...
...
@@ -317,6 +317,25 @@ dst_key_buildfilename(const dst_key_t *key, const int type, isc_buffer_t *out);
* be advanced.
*/
isc_result_t
dst_key_parsefilename
(
isc_buffer_t
*
source
,
isc_mem_t
*
mctx
,
char
**
name
,
isc_uint16_t
*
id
,
int
*
alg
,
char
**
suffix
);
/*
* Parses a dst key filename into its components.
*
* Requires:
* "source" is a valid buffer
* "mctx" is a valid memory context
* "name" is not NULL and "*name" is NULL
* "id" and "alg" are not NULL
* Either "suffix" is NULL or "suffix" is not NULL and "*suffix" is NULL
*
* Ensures:
* "*name" will point to allocated memory, as will "*suffix" if suffix
* is not NULL (strlen() + 1 bytes). The current pointer in source
* will be advanced.
*/
isc_result_t
dst_sig_size
(
const
dst_key_t
*
key
,
unsigned
int
*
n
);
/*
...
...
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