OpenCoverage

dh_asn1.c

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/libressl/src/crypto/dh/dh_asn1.c
Source codeSwitch to Preprocessed file
LineSourceCount
1/* $OpenBSD: dh_asn1.c,v 1.10 2016/12/30 15:26:49 jsing Exp $ */-
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL-
3 * project 2000.-
4 */-
5/* ====================================================================-
6 * Copyright (c) 2000-2005 The OpenSSL Project. All rights reserved.-
7 *-
8 * Redistribution and use in source and binary forms, with or without-
9 * modification, are permitted provided that the following conditions-
10 * are met:-
11 *-
12 * 1. Redistributions of source code must retain the above copyright-
13 * notice, this list of conditions and the following disclaimer. -
14 *-
15 * 2. Redistributions in binary form must reproduce the above copyright-
16 * notice, this list of conditions and the following disclaimer in-
17 * the documentation and/or other materials provided with the-
18 * distribution.-
19 *-
20 * 3. All advertising materials mentioning features or use of this-
21 * software must display the following acknowledgment:-
22 * "This product includes software developed by the OpenSSL Project-
23 * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"-
24 *-
25 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to-
26 * endorse or promote products derived from this software without-
27 * prior written permission. For written permission, please contact-
28 * licensing@OpenSSL.org.-
29 *-
30 * 5. Products derived from this software may not be called "OpenSSL"-
31 * nor may "OpenSSL" appear in their names without prior written-
32 * permission of the OpenSSL Project.-
33 *-
34 * 6. Redistributions of any form whatsoever must retain the following-
35 * acknowledgment:-
36 * "This product includes software developed by the OpenSSL Project-
37 * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"-
38 *-
39 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY-
40 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE-
41 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR-
42 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR-
43 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,-
44 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT-
45 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;-
46 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)-
47 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,-
48 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)-
49 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED-
50 * OF THE POSSIBILITY OF SUCH DAMAGE.-
51 * ====================================================================-
52 *-
53 * This product includes cryptographic software written by Eric Young-
54 * (eay@cryptsoft.com). This product includes software written by Tim-
55 * Hudson (tjh@cryptsoft.com).-
56 *-
57 */-
58-
59#include <stdio.h>-
60-
61#include <openssl/asn1t.h>-
62#include <openssl/bn.h>-
63#include <openssl/dh.h>-
64#include <openssl/objects.h>-
65-
66/* Override the default free and new methods */-
67static int-
68dh_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it, void *exarg)-
69{-
70 if (operation == ASN1_OP_NEW_PRE) {
operation == 0Description
TRUEevaluated 140 times by 1 test
Evaluated by:
  • ssltest
FALSEevaluated 700 times by 1 test
Evaluated by:
  • ssltest
140-700
71 *pval = (ASN1_VALUE *)DH_new();-
72 if (*pval)
*pvalDescription
TRUEevaluated 140 times by 1 test
Evaluated by:
  • ssltest
FALSEnever evaluated
0-140
73 return 2;
executed 140 times by 1 test: return 2;
Executed by:
  • ssltest
140
74 return 0;
never executed: return 0;
0
75 } else if (operation == ASN1_OP_FREE_PRE) {
operation == 2Description
TRUEnever evaluated
FALSEevaluated 700 times by 1 test
Evaluated by:
  • ssltest
0-700
76 DH_free((DH *)*pval);-
77 *pval = NULL;-
78 return 2;
never executed: return 2;
0
79 }-
80 return 1;
executed 700 times by 1 test: return 1;
Executed by:
  • ssltest
700
81}-
82-
83static const ASN1_AUX DHparams_aux = {-
84 .app_data = NULL,-
85 .flags = 0,-
86 .ref_offset = 0,-
87 .ref_lock = 0,-
88 .asn1_cb = dh_cb,-
89 .enc_offset = 0,-
90};-
91static const ASN1_TEMPLATE DHparams_seq_tt[] = {-
92 {-
93 .flags = 0,-
94 .tag = 0,-
95 .offset = offsetof(DH, p),-
96 .field_name = "p",-
97 .item = &BIGNUM_it,-
98 },-
99 {-
100 .flags = 0,-
101 .tag = 0,-
102 .offset = offsetof(DH, g),-
103 .field_name = "g",-
104 .item = &BIGNUM_it,-
105 },-
106 {-
107 .flags = ASN1_TFLG_OPTIONAL,-
108 .tag = 0,-
109 .offset = offsetof(DH, length),-
110 .field_name = "length",-
111 .item = &ZLONG_it,-
112 },-
113};-
114-
115const ASN1_ITEM DHparams_it = {-
116 .itype = ASN1_ITYPE_SEQUENCE,-
117 .utype = V_ASN1_SEQUENCE,-
118 .templates = DHparams_seq_tt,-
119 .tcount = sizeof(DHparams_seq_tt) / sizeof(ASN1_TEMPLATE),-
120 .funcs = &DHparams_aux,-
121 .size = sizeof(DH),-
122 .sname = "DH",-
123};-
124-
125-
126DH *-
127d2i_DHparams(DH **a, const unsigned char **in, long len)-
128{-
129 return (DH *)ASN1_item_d2i((ASN1_VALUE **)a, in, len,
never executed: return (DH *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, &DHparams_it);
0
130 &DHparams_it);
never executed: return (DH *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, &DHparams_it);
0
131}-
132-
133int-
134i2d_DHparams(const DH *a, unsigned char **out)-
135{-
136 return ASN1_item_i2d((ASN1_VALUE *)a, out, &DHparams_it);
never executed: return ASN1_item_i2d((ASN1_VALUE *)a, out, &DHparams_it);
0
137}-
138-
139DH *-
140d2i_DHparams_bio(BIO *bp, DH **a)-
141{-
142 return ASN1_item_d2i_bio(&DHparams_it, bp, a);
never executed: return ASN1_item_d2i_bio(&DHparams_it, bp, a);
0
143}-
144-
145int-
146i2d_DHparams_bio(BIO *bp, DH *a)-
147{-
148 return ASN1_item_i2d_bio(&DHparams_it, bp, a);
never executed: return ASN1_item_i2d_bio(&DHparams_it, bp, a);
0
149}-
150-
151DH *-
152d2i_DHparams_fp(FILE *fp, DH **a)-
153{-
154 return ASN1_item_d2i_fp(&DHparams_it, fp, a);
never executed: return ASN1_item_d2i_fp(&DHparams_it, fp, a);
0
155}-
156-
157int-
158i2d_DHparams_fp(FILE *fp, DH *a)-
159{-
160 return ASN1_item_i2d_fp(&DHparams_it, fp, a);
never executed: return ASN1_item_i2d_fp(&DHparams_it, fp, a);
0
161}-
162-
163DH *-
164DHparams_dup(DH *dh)-
165{-
166 return ASN1_item_dup(&DHparams_it, dh);
executed 140 times by 1 test: return ASN1_item_dup(&DHparams_it, dh);
Executed by:
  • ssltest
140
167}-
Source codeSwitch to Preprocessed file

Generated by Squish Coco 4.2.2