2001-10-11 11:42:52 +04:00
/*
2002-01-30 09:08:46 +03:00
Unix SMB / CIFS implementation .
2001-10-11 11:42:52 +04:00
simple SPNEGO routines
Copyright ( C ) Andrew Tridgell 2001
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
2007-07-09 23:25:36 +04:00
the Free Software Foundation ; either version 3 of the License , or
2001-10-11 11:42:52 +04:00
( 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
2007-07-10 04:52:41 +04:00
along with this program . If not , see < http : //www.gnu.org/licenses/>.
2001-10-11 11:42:52 +04:00
*/
# include "includes.h"
2001-10-11 14:29:17 +04:00
/* free an asn1 structure */
2001-10-11 11:42:52 +04:00
void asn1_free ( ASN1_DATA * data )
{
2007-02-20 09:22:20 +03:00
struct nesting * nesting = data - > nesting ;
while ( nesting ) {
struct nesting * nnext = nesting - > next ;
free ( nesting ) ;
nesting = nnext ;
} ;
data - > nesting = NULL ;
2001-10-11 14:29:17 +04:00
SAFE_FREE ( data - > data ) ;
2001-10-11 11:42:52 +04:00
}
2001-10-11 14:29:17 +04:00
/* write to the ASN1 buffer, advancing the buffer pointer */
2007-10-19 04:40:25 +04:00
bool asn1_write ( ASN1_DATA * data , const void * p , int len )
2001-10-11 11:42:52 +04:00
{
2001-10-11 17:13:06 +04:00
if ( data - > has_error ) return False ;
2001-10-11 11:42:52 +04:00
if ( data - > length < data - > ofs + len ) {
2006-07-15 14:55:24 +04:00
data - > data = SMB_REALLOC_ARRAY ( data - > data , unsigned char ,
data - > ofs + len ) ;
r13915: Fixed a very interesting class of realloc() bugs found by Coverity.
realloc can return NULL in one of two cases - (1) the realloc failed,
(2) realloc succeeded but the new size requested was zero, in which
case this is identical to a free() call.
The error paths dealing with these two cases should be different,
but mostly weren't. Secondly the standard idiom for dealing with
realloc when you know the new size is non-zero is the following :
tmp = realloc(p, size);
if (!tmp) {
SAFE_FREE(p);
return error;
} else {
p = tmp;
}
However, there were *many* *many* places in Samba where we were
using the old (broken) idiom of :
p = realloc(p, size)
if (!p) {
return error;
}
which will leak the memory pointed to by p on realloc fail.
This commit (hopefully) fixes all these cases by moving to
a standard idiom of :
p = SMB_REALLOC(p, size)
if (!p) {
return error;
}
Where if the realloc returns null due to the realloc failing
or size == 0 we *guarentee* that the storage pointed to by p
has been freed. This allows me to remove a lot of code that
was dealing with the standard (more verbose) method that required
a tmp pointer. This is almost always what you want. When a
realloc fails you never usually want the old memory, you
want to free it and get into your error processing asap.
For the 11 remaining cases where we really do need to keep the
old pointer I have invented the new macro SMB_REALLOC_KEEP_OLD_ON_ERROR,
which can be used as follows :
tmp = SMB_REALLOC_KEEP_OLD_ON_ERROR(p, size);
if (!tmp) {
SAFE_FREE(p);
return error;
} else {
p = tmp;
}
SMB_REALLOC_KEEP_OLD_ON_ERROR guarentees never to free the
pointer p, even on size == 0 or realloc fail. All this is
done by a hidden extra argument to Realloc(), BOOL free_old_on_error
which is set appropriately by the SMB_REALLOC and SMB_REALLOC_KEEP_OLD_ON_ERROR
macros (and their array counterparts).
It remains to be seen what this will do to our Coverity bug count :-).
Jeremy.
(This used to be commit 1d710d06a214f3f1740e80e0bffd6aab44aac2b0)
2006-03-07 09:31:04 +03:00
if ( ! data - > data ) {
2001-10-11 17:13:06 +04:00
data - > has_error = True ;
return False ;
}
2001-10-11 11:42:52 +04:00
data - > length = data - > ofs + len ;
}
memcpy ( data - > data + data - > ofs , p , len ) ;
data - > ofs + = len ;
return True ;
}
2001-10-11 14:29:17 +04:00
/* useful fn for writing a uint8 */
2007-10-19 04:40:25 +04:00
bool asn1_write_uint8 ( ASN1_DATA * data , uint8 v )
2001-10-11 11:42:52 +04:00
{
return asn1_write ( data , & v , 1 ) ;
}
2001-10-11 14:29:17 +04:00
/* push a tag onto the asn1 data buffer. Used for nested structures */
2007-10-19 04:40:25 +04:00
bool asn1_push_tag ( ASN1_DATA * data , uint8 tag )
2001-10-11 11:42:52 +04:00
{
struct nesting * nesting ;
asn1_write_uint8 ( data , tag ) ;
2004-12-07 21:25:53 +03:00
nesting = SMB_MALLOC_P ( struct nesting ) ;
2001-10-11 17:13:06 +04:00
if ( ! nesting ) {
data - > has_error = True ;
return False ;
}
2001-10-11 11:42:52 +04:00
nesting - > start = data - > ofs ;
nesting - > next = data - > nesting ;
data - > nesting = nesting ;
2001-10-11 17:13:06 +04:00
return asn1_write_uint8 ( data , 0xff ) ;
2001-10-11 11:42:52 +04:00
}
2001-10-11 14:29:17 +04:00
/* pop a tag */
2007-10-19 04:40:25 +04:00
bool asn1_pop_tag ( ASN1_DATA * data )
2001-10-11 11:42:52 +04:00
{
struct nesting * nesting ;
size_t len ;
2006-10-04 23:09:32 +04:00
if ( data - > has_error ) {
return False ;
}
2001-10-11 11:42:52 +04:00
nesting = data - > nesting ;
if ( ! nesting ) {
2001-10-11 17:13:06 +04:00
data - > has_error = True ;
2001-10-11 11:42:52 +04:00
return False ;
}
len = data - > ofs - ( nesting - > start + 1 ) ;
2001-10-11 14:29:17 +04:00
/* yes, this is ugly. We don't know in advance how many bytes the length
of a tag will take , so we assumed 1 byte . If we were wrong then we
need to correct our mistake */
2005-06-27 22:53:38 +04:00
if ( len > 0xFFFF ) {
data - > data [ nesting - > start ] = 0x83 ;
if ( ! asn1_write_uint8 ( data , 0 ) ) return False ;
if ( ! asn1_write_uint8 ( data , 0 ) ) return False ;
if ( ! asn1_write_uint8 ( data , 0 ) ) return False ;
memmove ( data - > data + nesting - > start + 4 , data - > data + nesting - > start + 1 , len ) ;
data - > data [ nesting - > start + 1 ] = ( len > > 16 ) & 0xFF ;
data - > data [ nesting - > start + 2 ] = ( len > > 8 ) & 0xFF ;
data - > data [ nesting - > start + 3 ] = len & 0xff ;
} else if ( len > 255 ) {
2001-10-11 11:42:52 +04:00
data - > data [ nesting - > start ] = 0x82 ;
2001-10-11 17:13:06 +04:00
if ( ! asn1_write_uint8 ( data , 0 ) ) return False ;
if ( ! asn1_write_uint8 ( data , 0 ) ) return False ;
2001-10-11 11:42:52 +04:00
memmove ( data - > data + nesting - > start + 3 , data - > data + nesting - > start + 1 , len ) ;
data - > data [ nesting - > start + 1 ] = len > > 8 ;
data - > data [ nesting - > start + 2 ] = len & 0xff ;
2001-10-17 12:54:19 +04:00
} else if ( len > 127 ) {
data - > data [ nesting - > start ] = 0x81 ;
if ( ! asn1_write_uint8 ( data , 0 ) ) return False ;
memmove ( data - > data + nesting - > start + 2 , data - > data + nesting - > start + 1 , len ) ;
data - > data [ nesting - > start + 1 ] = len ;
2001-10-11 11:42:52 +04:00
} else {
data - > data [ nesting - > start ] = len ;
}
data - > nesting = nesting - > next ;
free ( nesting ) ;
return True ;
}
2001-11-20 11:46:02 +03:00
/* write an integer */
2007-10-19 04:40:25 +04:00
bool asn1_write_Integer ( ASN1_DATA * data , int i )
2001-11-20 11:46:02 +03:00
{
if ( ! asn1_push_tag ( data , ASN1_INTEGER ) ) return False ;
do {
asn1_write_uint8 ( data , i ) ;
i = i > > 8 ;
} while ( i ) ;
return asn1_pop_tag ( data ) ;
}
2001-10-11 14:29:17 +04:00
/* write an object ID to a ASN1 buffer */
2007-10-19 04:40:25 +04:00
bool asn1_write_OID ( ASN1_DATA * data , const char * OID )
2001-10-11 11:42:52 +04:00
{
unsigned v , v2 ;
2001-11-04 02:34:24 +03:00
const char * p = ( const char * ) OID ;
char * newp ;
2001-10-11 11:42:52 +04:00
2001-11-04 02:34:24 +03:00
if ( ! asn1_push_tag ( data , ASN1_OID ) )
return False ;
v = strtol ( p , & newp , 10 ) ;
p = newp ;
v2 = strtol ( p , & newp , 10 ) ;
p = newp ;
if ( ! asn1_write_uint8 ( data , 40 * v + v2 ) )
return False ;
2001-10-11 11:42:52 +04:00
while ( * p ) {
2001-11-04 02:34:24 +03:00
v = strtol ( p , & newp , 10 ) ;
p = newp ;
2001-10-11 11:42:52 +04:00
if ( v > = ( 1 < < 28 ) ) asn1_write_uint8 ( data , 0x80 | ( ( v > > 28 ) & 0xff ) ) ;
if ( v > = ( 1 < < 21 ) ) asn1_write_uint8 ( data , 0x80 | ( ( v > > 21 ) & 0xff ) ) ;
if ( v > = ( 1 < < 14 ) ) asn1_write_uint8 ( data , 0x80 | ( ( v > > 14 ) & 0xff ) ) ;
if ( v > = ( 1 < < 7 ) ) asn1_write_uint8 ( data , 0x80 | ( ( v > > 7 ) & 0xff ) ) ;
2001-11-04 02:34:24 +03:00
if ( ! asn1_write_uint8 ( data , v & 0x7f ) )
return False ;
2001-10-11 11:42:52 +04:00
}
2001-10-11 17:13:06 +04:00
return asn1_pop_tag ( data ) ;
2001-10-11 11:42:52 +04:00
}
2001-10-11 14:29:17 +04:00
/* write an octet string */
2007-10-19 04:40:25 +04:00
bool asn1_write_OctetString ( ASN1_DATA * data , const void * p , size_t length )
2001-10-11 11:42:52 +04:00
{
asn1_push_tag ( data , ASN1_OCTET_STRING ) ;
asn1_write ( data , p , length ) ;
asn1_pop_tag ( data ) ;
2001-10-11 17:13:06 +04:00
return ! data - > has_error ;
2001-10-11 11:42:52 +04:00
}
2001-10-11 14:29:17 +04:00
/* write a general string */
2007-10-19 04:40:25 +04:00
bool asn1_write_GeneralString ( ASN1_DATA * data , const char * s )
2001-10-11 11:42:52 +04:00
{
asn1_push_tag ( data , ASN1_GENERAL_STRING ) ;
asn1_write ( data , s , strlen ( s ) ) ;
asn1_pop_tag ( data ) ;
2001-10-11 17:13:06 +04:00
return ! data - > has_error ;
2001-10-11 11:42:52 +04:00
}
2001-10-11 14:29:17 +04:00
/* write a BOOLEAN */
2007-10-19 04:40:25 +04:00
bool asn1_write_BOOLEAN ( ASN1_DATA * data , bool v )
2001-10-11 11:42:52 +04:00
{
asn1_write_uint8 ( data , ASN1_BOOLEAN ) ;
asn1_write_uint8 ( data , v ) ;
2001-10-11 17:13:06 +04:00
return ! data - > has_error ;
2001-10-11 11:42:52 +04:00
}
2002-09-25 19:19:00 +04:00
/* write a BOOLEAN - hmm, I suspect this one is the correct one, and the
above boolean is bogus . Need to check */
2007-10-19 04:40:25 +04:00
bool asn1_write_BOOLEAN2 ( ASN1_DATA * data , bool v )
2002-09-25 19:19:00 +04:00
{
asn1_push_tag ( data , ASN1_BOOLEAN ) ;
asn1_write_uint8 ( data , v ) ;
asn1_pop_tag ( data ) ;
return ! data - > has_error ;
}
2001-10-18 14:26:06 +04:00
/* check a BOOLEAN */
2007-10-19 04:40:25 +04:00
bool asn1_check_BOOLEAN ( ASN1_DATA * data , bool v )
2001-10-18 14:26:06 +04:00
{
uint8 b = 0 ;
asn1_read_uint8 ( data , & b ) ;
if ( b ! = ASN1_BOOLEAN ) {
data - > has_error = True ;
return False ;
}
asn1_read_uint8 ( data , & b ) ;
if ( b ! = v ) {
data - > has_error = True ;
return False ;
}
return ! data - > has_error ;
}
2001-10-11 14:29:17 +04:00
/* load a ASN1_DATA structure with a lump of data, ready to be parsed */
2007-10-19 04:40:25 +04:00
bool asn1_load ( ASN1_DATA * data , DATA_BLOB blob )
2001-10-11 14:29:17 +04:00
{
ZERO_STRUCTP ( data ) ;
2006-07-15 14:55:24 +04:00
data - > data = ( unsigned char * ) memdup ( blob . data , blob . length ) ;
2001-10-11 17:13:06 +04:00
if ( ! data - > data ) {
data - > has_error = True ;
return False ;
}
data - > length = blob . length ;
2001-10-11 14:29:17 +04:00
return True ;
}
/* read from a ASN1 buffer, advancing the buffer pointer */
2007-10-19 04:40:25 +04:00
bool asn1_read ( ASN1_DATA * data , void * p , int len )
2001-10-11 14:29:17 +04:00
{
2004-09-16 00:33:03 +04:00
if ( data - > has_error )
return False ;
2004-02-12 02:25:51 +03:00
if ( len < 0 | | data - > ofs + len < data - > ofs | | data - > ofs + len < len ) {
data - > has_error = True ;
return False ;
}
2001-10-11 14:29:17 +04:00
if ( data - > ofs + len > data - > length ) {
2001-10-11 17:13:06 +04:00
data - > has_error = True ;
2001-10-11 14:29:17 +04:00
return False ;
}
memcpy ( p , data - > data + data - > ofs , len ) ;
data - > ofs + = len ;
return True ;
}
2001-10-11 17:13:06 +04:00
/* read a uint8 from a ASN1 buffer */
2007-10-19 04:40:25 +04:00
bool asn1_read_uint8 ( ASN1_DATA * data , uint8 * v )
2001-10-11 17:13:06 +04:00
{
return asn1_read ( data , v , 1 ) ;
}
2001-10-11 14:29:17 +04:00
2001-10-11 17:13:06 +04:00
/* start reading a nested asn1 structure */
2007-10-19 04:40:25 +04:00
bool asn1_start_tag ( ASN1_DATA * data , uint8 tag )
2001-10-11 17:13:06 +04:00
{
uint8 b ;
struct nesting * nesting ;
2003-02-19 15:31:16 +03:00
if ( ! asn1_read_uint8 ( data , & b ) )
return False ;
2001-10-11 17:13:06 +04:00
if ( b ! = tag ) {
data - > has_error = True ;
return False ;
}
2004-12-07 21:25:53 +03:00
nesting = SMB_MALLOC_P ( struct nesting ) ;
2001-10-11 17:13:06 +04:00
if ( ! nesting ) {
data - > has_error = True ;
return False ;
}
2003-02-19 15:31:16 +03:00
if ( ! asn1_read_uint8 ( data , & b ) ) {
2006-06-13 22:15:03 +04:00
SAFE_FREE ( nesting ) ;
2003-02-19 15:31:16 +03:00
return False ;
}
2001-10-11 17:13:06 +04:00
if ( b & 0x80 ) {
int n = b & 0x7f ;
2006-06-13 22:15:03 +04:00
if ( ! asn1_read_uint8 ( data , & b ) ) {
SAFE_FREE ( nesting ) ;
2003-02-19 15:31:16 +03:00
return False ;
2006-06-13 22:15:03 +04:00
}
2001-10-17 12:54:19 +04:00
nesting - > taglen = b ;
2002-09-25 19:19:00 +04:00
while ( n > 1 ) {
2006-06-13 22:15:03 +04:00
if ( ! asn1_read_uint8 ( data , & b ) ) {
SAFE_FREE ( nesting ) ;
2003-02-19 15:31:16 +03:00
return False ;
2006-06-13 22:15:03 +04:00
}
2001-10-17 12:54:19 +04:00
nesting - > taglen = ( nesting - > taglen < < 8 ) | b ;
2002-09-25 19:19:00 +04:00
n - - ;
2001-10-17 12:54:19 +04:00
}
2001-10-11 17:13:06 +04:00
} else {
nesting - > taglen = b ;
}
nesting - > start = data - > ofs ;
nesting - > next = data - > nesting ;
data - > nesting = nesting ;
return ! data - > has_error ;
}
/* stop reading a tag */
2007-10-19 04:40:25 +04:00
bool asn1_end_tag ( ASN1_DATA * data )
2001-10-11 17:13:06 +04:00
{
struct nesting * nesting ;
/* make sure we read it all */
if ( asn1_tag_remaining ( data ) ! = 0 ) {
data - > has_error = True ;
return False ;
}
nesting = data - > nesting ;
if ( ! nesting ) {
data - > has_error = True ;
return False ;
}
data - > nesting = nesting - > next ;
free ( nesting ) ;
return True ;
}
/* work out how many bytes are left in this nested tag */
int asn1_tag_remaining ( ASN1_DATA * data )
{
2004-09-16 00:33:03 +04:00
if ( data - > has_error )
return 0 ;
2001-10-11 17:13:06 +04:00
if ( ! data - > nesting ) {
data - > has_error = True ;
return - 1 ;
}
return data - > nesting - > taglen - ( data - > ofs - data - > nesting - > start ) ;
}
/* read an object ID from a ASN1 buffer */
2007-10-19 04:40:25 +04:00
bool asn1_read_OID ( ASN1_DATA * data , char * * OID )
2001-10-11 17:13:06 +04:00
{
2007-11-28 10:40:54 +03:00
uint8 b = 0 ;
char * oid_str = NULL ;
2001-10-11 17:13:06 +04:00
2006-06-14 01:01:08 +04:00
* OID = NULL ;
if ( ! asn1_start_tag ( data , ASN1_OID ) ) {
2007-11-28 10:40:54 +03:00
return false ;
2006-06-14 01:01:08 +04:00
}
2001-10-11 17:13:06 +04:00
asn1_read_uint8 ( data , & b ) ;
2007-11-28 10:40:54 +03:00
oid_str = talloc_asprintf ( NULL ,
" %u " ,
b / 40 ) ;
if ( ! oid_str ) {
data - > has_error = true ;
goto out ;
}
oid_str = talloc_asprintf_append ( oid_str ,
" %u " ,
b % 40 ) ;
if ( ! oid_str ) {
data - > has_error = true ;
goto out ;
}
2001-10-11 17:13:06 +04:00
while ( asn1_tag_remaining ( data ) > 0 ) {
unsigned v = 0 ;
do {
asn1_read_uint8 ( data , & b ) ;
v = ( v < < 7 ) | ( b & 0x7f ) ;
} while ( ! data - > has_error & & b & 0x80 ) ;
2007-11-28 10:40:54 +03:00
oid_str = talloc_asprintf_append ( oid_str ,
" %u " ,
v ) ;
if ( ! oid_str ) {
data - > has_error = true ;
goto out ;
}
2001-10-11 17:13:06 +04:00
}
2007-11-28 10:40:54 +03:00
out :
2001-10-11 17:13:06 +04:00
asn1_end_tag ( data ) ;
2006-06-14 01:01:08 +04:00
if ( ! data - > has_error ) {
* OID = SMB_STRDUP ( oid_str ) ;
}
2001-10-11 17:13:06 +04:00
2007-11-28 10:40:54 +03:00
TALLOC_FREE ( oid_str ) ;
2001-10-11 17:13:06 +04:00
return ! data - > has_error ;
}
/* check that the next object ID is correct */
2007-10-19 04:40:25 +04:00
bool asn1_check_OID ( ASN1_DATA * data , const char * OID )
2001-10-11 17:13:06 +04:00
{
char * id ;
2006-06-14 01:01:08 +04:00
if ( ! asn1_read_OID ( data , & id ) ) {
return False ;
}
2001-10-11 17:13:06 +04:00
if ( strcmp ( id , OID ) ! = 0 ) {
data - > has_error = True ;
return False ;
}
free ( id ) ;
return True ;
}
/* read a GeneralString from a ASN1 buffer */
2007-10-19 04:40:25 +04:00
bool asn1_read_GeneralString ( ASN1_DATA * data , char * * s )
2001-10-11 17:13:06 +04:00
{
int len ;
2006-06-17 02:25:17 +04:00
char * str ;
* s = NULL ;
if ( ! asn1_start_tag ( data , ASN1_GENERAL_STRING ) ) {
return False ;
}
2001-10-11 17:13:06 +04:00
len = asn1_tag_remaining ( data ) ;
2004-02-11 22:59:17 +03:00
if ( len < 0 ) {
data - > has_error = True ;
return False ;
}
2006-07-15 14:55:24 +04:00
str = SMB_MALLOC_ARRAY ( char , len + 1 ) ;
2006-06-17 02:25:17 +04:00
if ( ! str ) {
2001-10-11 17:13:06 +04:00
data - > has_error = True ;
return False ;
}
2006-06-17 02:25:17 +04:00
asn1_read ( data , str , len ) ;
str [ len ] = 0 ;
2001-10-11 17:13:06 +04:00
asn1_end_tag ( data ) ;
2006-06-17 02:25:17 +04:00
if ( ! data - > has_error ) {
* s = str ;
}
2001-10-11 17:13:06 +04:00
return ! data - > has_error ;
}
2001-10-12 08:49:42 +04:00
/* read a octet string blob */
2007-10-19 04:40:25 +04:00
bool asn1_read_OctetString ( ASN1_DATA * data , DATA_BLOB * blob )
2001-10-12 08:49:42 +04:00
{
int len ;
2002-09-25 19:19:00 +04:00
ZERO_STRUCTP ( blob ) ;
2001-10-12 08:49:42 +04:00
if ( ! asn1_start_tag ( data , ASN1_OCTET_STRING ) ) return False ;
len = asn1_tag_remaining ( data ) ;
2004-02-11 22:59:17 +03:00
if ( len < 0 ) {
data - > has_error = True ;
return False ;
}
2002-01-06 02:34:06 +03:00
* blob = data_blob ( NULL , len ) ;
2001-10-12 08:49:42 +04:00
asn1_read ( data , blob - > data , len ) ;
asn1_end_tag ( data ) ;
return ! data - > has_error ;
}
2001-11-20 11:46:02 +03:00
/* read an interger */
2007-10-19 04:40:25 +04:00
bool asn1_read_Integer ( ASN1_DATA * data , int * i )
2001-11-20 11:46:02 +03:00
{
uint8 b ;
* i = 0 ;
if ( ! asn1_start_tag ( data , ASN1_INTEGER ) ) return False ;
while ( asn1_tag_remaining ( data ) > 0 ) {
2002-09-25 19:19:00 +04:00
asn1_read_uint8 ( data , & b ) ;
* i = ( * i < < 8 ) + b ;
2001-11-20 11:46:02 +03:00
}
return asn1_end_tag ( data ) ;
}
2001-10-12 08:49:42 +04:00
/* check a enumarted value is correct */
2007-10-19 04:40:25 +04:00
bool asn1_check_enumerated ( ASN1_DATA * data , int v )
2001-10-12 08:49:42 +04:00
{
uint8 b ;
if ( ! asn1_start_tag ( data , ASN1_ENUMERATED ) ) return False ;
asn1_read_uint8 ( data , & b ) ;
asn1_end_tag ( data ) ;
2003-02-19 15:31:16 +03:00
if ( v ! = b )
data - > has_error = False ;
return ! data - > has_error ;
2001-10-12 08:49:42 +04:00
}
2001-10-17 12:54:19 +04:00
2003-01-15 20:22:48 +03:00
/* write an enumarted value to the stream */
2007-10-19 04:40:25 +04:00
bool asn1_write_enumerated ( ASN1_DATA * data , uint8 v )
2001-10-17 12:54:19 +04:00
{
if ( ! asn1_push_tag ( data , ASN1_ENUMERATED ) ) return False ;
asn1_write_uint8 ( data , v ) ;
asn1_pop_tag ( data ) ;
return ! data - > has_error ;
}