/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include <errno.h>
#include <ctype.h>
#include <cryptoutil.h>
/*
* tohexstr
* IN bytes
* blen
* hexlen should be 2 * blen + 1
* OUT
* hexstr
*/
void
{
size_t i;
for (i = 0; i < blen; i++) {
break;
}
}
/*
* This function takes a char[] and length of hexadecimal values and
* returns a malloc'ed byte array with the length of that new byte array.
* The caller needs to provide a pointer to where this new malloc'ed byte array
* will be passed back; as well as, a pointer for the length of the new
* byte array.
*
* The caller is responsible for freeing the malloc'ed array when done
*
* The return code is 0 if successful, otherwise the errno value is returned.
*/
int
{
int i, ret = 0;
unsigned char ch;
*blen = 0;
return (EINVAL);
hexstr += 2;
hexlen -= 2;
}
if (b == NULL) {
*blen = 0;
return (errno);
}
for (i = 0; i < hexlen; i++) {
goto out;
}
hexstr++;
ch -= '0';
if (i & 1)
b[i/2] |= ch;
else
}
out:
free(b);
*blen = 0;
} else
*bytes = b;
return (ret);
}