1215976Sjmallett/* crypto/x509/x509rset.c */
2215976Sjmallett/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3215976Sjmallett * All rights reserved.
4215976Sjmallett *
5215976Sjmallett * This package is an SSL implementation written
6215976Sjmallett * by Eric Young (eay@cryptsoft.com).
7215976Sjmallett * The implementation was written so as to conform with Netscapes SSL.
8215976Sjmallett *
9215976Sjmallett * This library is free for commercial and non-commercial use as long as
10215976Sjmallett * the following conditions are aheared to.  The following conditions
11215976Sjmallett * apply to all code found in this distribution, be it the RC4, RSA,
12215976Sjmallett * lhash, DES, etc., code; not just the SSL code.  The SSL documentation
13215976Sjmallett * included with this distribution is covered by the same copyright terms
14215976Sjmallett * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15215976Sjmallett *
16215976Sjmallett * Copyright remains Eric Young's, and as such any Copyright notices in
17215976Sjmallett * the code are not to be removed.
18215976Sjmallett * If this package is used in a product, Eric Young should be given attribution
19215976Sjmallett * as the author of the parts of the library used.
20215976Sjmallett * This can be in the form of a textual message at program startup or
21215976Sjmallett * in documentation (online or textual) provided with the package.
22215976Sjmallett *
23215976Sjmallett * Redistribution and use in source and binary forms, with or without
24215976Sjmallett * modification, are permitted provided that the following conditions
25215976Sjmallett * are met:
26215976Sjmallett * 1. Redistributions of source code must retain the copyright
27215976Sjmallett *    notice, this list of conditions and the following disclaimer.
28215976Sjmallett * 2. Redistributions in binary form must reproduce the above copyright
29215976Sjmallett *    notice, this list of conditions and the following disclaimer in the
30215976Sjmallett *    documentation and/or other materials provided with the distribution.
31215976Sjmallett * 3. All advertising materials mentioning features or use of this software
32215976Sjmallett *    must display the following acknowledgement:
33215976Sjmallett *    "This product includes cryptographic software written by
34215976Sjmallett *     Eric Young (eay@cryptsoft.com)"
35215976Sjmallett *    The word 'cryptographic' can be left out if the rouines from the library
36215976Sjmallett *    being used are not cryptographic related :-).
37215976Sjmallett * 4. If you include any Windows specific code (or a derivative thereof) from
38215976Sjmallett *    the apps directory (application code) you must include an acknowledgement:
39215976Sjmallett *    "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40215976Sjmallett *
41215976Sjmallett * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42215976Sjmallett * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43215976Sjmallett * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44215976Sjmallett * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45215976Sjmallett * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46215976Sjmallett * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47215976Sjmallett * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48215976Sjmallett * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49215976Sjmallett * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50215976Sjmallett * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51215976Sjmallett * SUCH DAMAGE.
52215976Sjmallett *
53215976Sjmallett * The licence and distribution terms for any publically available version or
54215976Sjmallett * derivative of this code cannot be changed.  i.e. this code cannot simply be
55215976Sjmallett * copied and put under another distribution licence
56215976Sjmallett * [including the GNU Public Licence.]
57215976Sjmallett */
58215976Sjmallett
59215976Sjmallett#include <stdio.h>
60215976Sjmallett#include "cryptlib.h"
61215976Sjmallett#include <openssl/asn1.h>
62215976Sjmallett#include <openssl/objects.h>
63215976Sjmallett#include <openssl/evp.h>
64215976Sjmallett#include <openssl/x509.h>
65215990Sjmallett
66215976Sjmallettint X509_REQ_set_version(X509_REQ *x, long version)
67215976Sjmallett{
68215976Sjmallett    if (x == NULL)
69215976Sjmallett        return (0);
70215976Sjmallett    return (ASN1_INTEGER_set(x->req_info->version, version));
71215976Sjmallett}
72215976Sjmallett
73215976Sjmallettint X509_REQ_set_subject_name(X509_REQ *x, X509_NAME *name)
74215990Sjmallett{
75215990Sjmallett    if ((x == NULL) || (x->req_info == NULL))
76215990Sjmallett        return (0);
77215990Sjmallett    return (X509_NAME_set(&x->req_info->subject, name));
78215976Sjmallett}
79215990Sjmallett
80215976Sjmallettint X509_REQ_set_pubkey(X509_REQ *x, EVP_PKEY *pkey)
81215976Sjmallett{
82215976Sjmallett    if ((x == NULL) || (x->req_info == NULL))
83215976Sjmallett        return (0);
84215976Sjmallett    return (X509_PUBKEY_set(&x->req_info->pubkey, pkey));
85215976Sjmallett}
86215976Sjmallett