a_octet.c revision 59191
1303231Sdim/* crypto/asn1/a_octet.c */
2303231Sdim/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3353358Sdim * All rights reserved.
4353358Sdim *
5353358Sdim * This package is an SSL implementation written
6303231Sdim * by Eric Young (eay@cryptsoft.com).
7303231Sdim * The implementation was written so as to conform with Netscapes SSL.
8303231Sdim *
9303231Sdim * This library is free for commercial and non-commercial use as long as
10341825Sdim * the following conditions are aheared to.  The following conditions
11327952Sdim * apply to all code found in this distribution, be it the RC4, RSA,
12303231Sdim * lhash, DES, etc., code; not just the SSL code.  The SSL documentation
13303231Sdim * included with this distribution is covered by the same copyright terms
14303231Sdim * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15303231Sdim *
16303231Sdim * Copyright remains Eric Young's, and as such any Copyright notices in
17303231Sdim * the code are not to be removed.
18303231Sdim * If this package is used in a product, Eric Young should be given attribution
19303231Sdim * as the author of the parts of the library used.
20303231Sdim * This can be in the form of a textual message at program startup or
21303231Sdim * in documentation (online or textual) provided with the package.
22303231Sdim *
23303231Sdim * Redistribution and use in source and binary forms, with or without
24303231Sdim * modification, are permitted provided that the following conditions
25303231Sdim * are met:
26303231Sdim * 1. Redistributions of source code must retain the copyright
27303231Sdim *    notice, this list of conditions and the following disclaimer.
28303231Sdim * 2. Redistributions in binary form must reproduce the above copyright
29303231Sdim *    notice, this list of conditions and the following disclaimer in the
30303231Sdim *    documentation and/or other materials provided with the distribution.
31327952Sdim * 3. All advertising materials mentioning features or use of this software
32327952Sdim *    must display the following acknowledgement:
33327952Sdim *    "This product includes cryptographic software written by
34327952Sdim *     Eric Young (eay@cryptsoft.com)"
35327952Sdim *    The word 'cryptographic' can be left out if the rouines from the library
36327952Sdim *    being used are not cryptographic related :-).
37327952Sdim * 4. If you include any Windows specific code (or a derivative thereof) from
38303231Sdim *    the apps directory (application code) you must include an acknowledgement:
39303231Sdim *    "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40303231Sdim *
41303231Sdim * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42303231Sdim * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43303231Sdim * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44303231Sdim * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45303231Sdim * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46303231Sdim * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47303231Sdim * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48303231Sdim * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49303231Sdim * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50303231Sdim * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51303231Sdim * SUCH DAMAGE.
52303231Sdim *
53303231Sdim * The licence and distribution terms for any publically available version or
54303231Sdim * derivative of this code cannot be changed.  i.e. this code cannot simply be
55303231Sdim * copied and put under another distribution licence
56303231Sdim * [including the GNU Public Licence.]
57303231Sdim */
58303231Sdim
59303231Sdim#include <stdio.h>
60360784Sdim#include "cryptlib.h"
61303231Sdim#include <openssl/asn1.h>
62303231Sdim
63314564SdimASN1_OCTET_STRING *ASN1_OCTET_STRING_new(void)
64327952Sdim{ return M_ASN1_OCTET_STRING_new(); }
65314564Sdim
66314564Sdimvoid ASN1_OCTET_STRING_free(ASN1_OCTET_STRING *x)
67314564Sdim{ M_ASN1_OCTET_STRING_free(x); }
68327952Sdim
69314564SdimASN1_OCTET_STRING *ASN1_OCTET_STRING_dup(ASN1_OCTET_STRING *x)
70303231Sdim{ return M_ASN1_OCTET_STRING_dup(x); }
71303231Sdim
72314564Sdimint ASN1_OCTET_STRING_cmp(ASN1_OCTET_STRING *a, ASN1_OCTET_STRING *b)
73303231Sdim{ return M_ASN1_OCTET_STRING_cmp(a, b); }
74314564Sdim
75303231Sdimint ASN1_OCTET_STRING_set(ASN1_OCTET_STRING *x, unsigned char *d, int len)
76314564Sdim{ return M_ASN1_OCTET_STRING_set(x, d, len); }
77327952Sdim
78314564Sdimint i2d_ASN1_OCTET_STRING(ASN1_OCTET_STRING *a, unsigned char **pp)
79314564Sdim{ return M_i2d_ASN1_OCTET_STRING(a, pp); }
80360784Sdim
81314564SdimASN1_OCTET_STRING *d2i_ASN1_OCTET_STRING(ASN1_OCTET_STRING **a,
82314564Sdim	     unsigned char **pp, long length)
83314564Sdim	{
84314564Sdim	ASN1_OCTET_STRING *ret=NULL;
85314564Sdim
86314564Sdim	ret=(ASN1_OCTET_STRING *)d2i_ASN1_bytes((ASN1_STRING **)a,
87303231Sdim		pp,length,V_ASN1_OCTET_STRING,V_ASN1_UNIVERSAL);
88303231Sdim	if (ret == NULL)
89303231Sdim		{
90303231Sdim		ASN1err(ASN1_F_D2I_ASN1_OCTET_STRING,ERR_R_NESTED_ASN1_ERROR);
91303231Sdim		return(NULL);
92303231Sdim		}
93303231Sdim	return(ret);
94303231Sdim	}
95303231Sdim
96327952Sdim