Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(285)

Side by Side Diff: nss/lib/freebl/ecl/ecl_curve.c

Issue 2078763002: Delete bundled copy of NSS and replace with README. (Closed) Base URL: https://chromium.googlesource.com/chromium/deps/nss@master
Patch Set: Delete bundled copy of NSS and replace with README. Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « nss/lib/freebl/ecl/ecl-priv.h ('k') | nss/lib/freebl/ecl/ecl_gf.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4
5 #include "ecl.h"
6 #include "ecl-curve.h"
7 #include "ecl-priv.h"
8 #include <stdlib.h>
9 #include <string.h>
10
11 #define CHECK(func) if ((func) == NULL) { res = 0; goto CLEANUP; }
12
13 /* Duplicates an ECCurveParams */
14 ECCurveParams *
15 ECCurveParams_dup(const ECCurveParams * params)
16 {
17 int res = 1;
18 ECCurveParams *ret = NULL;
19
20 CHECK(ret = (ECCurveParams *) calloc(1, sizeof(ECCurveParams)));
21 if (params->text != NULL) {
22 CHECK(ret->text = strdup(params->text));
23 }
24 ret->field = params->field;
25 ret->size = params->size;
26 if (params->irr != NULL) {
27 CHECK(ret->irr = strdup(params->irr));
28 }
29 if (params->curvea != NULL) {
30 CHECK(ret->curvea = strdup(params->curvea));
31 }
32 if (params->curveb != NULL) {
33 CHECK(ret->curveb = strdup(params->curveb));
34 }
35 if (params->genx != NULL) {
36 CHECK(ret->genx = strdup(params->genx));
37 }
38 if (params->geny != NULL) {
39 CHECK(ret->geny = strdup(params->geny));
40 }
41 if (params->order != NULL) {
42 CHECK(ret->order = strdup(params->order));
43 }
44 ret->cofactor = params->cofactor;
45
46 CLEANUP:
47 if (res != 1) {
48 EC_FreeCurveParams(ret);
49 return NULL;
50 }
51 return ret;
52 }
53
54 #undef CHECK
55
56 /* Construct ECCurveParams from an ECCurveName */
57 ECCurveParams *
58 EC_GetNamedCurveParams(const ECCurveName name)
59 {
60 if ((name <= ECCurve_noName) || (ECCurve_pastLastCurve <= name) ||
61 (ecCurve_map[name] == NULL)) {
62 return NULL;
63 } else {
64 return ECCurveParams_dup(ecCurve_map[name]);
65 }
66 }
67
68 /* Free the memory allocated (if any) to an ECCurveParams object. */
69 void
70 EC_FreeCurveParams(ECCurveParams * params)
71 {
72 if (params == NULL)
73 return;
74 if (params->text != NULL)
75 free(params->text);
76 if (params->irr != NULL)
77 free(params->irr);
78 if (params->curvea != NULL)
79 free(params->curvea);
80 if (params->curveb != NULL)
81 free(params->curveb);
82 if (params->genx != NULL)
83 free(params->genx);
84 if (params->geny != NULL)
85 free(params->geny);
86 if (params->order != NULL)
87 free(params->order);
88 free(params);
89 }
OLDNEW
« no previous file with comments | « nss/lib/freebl/ecl/ecl-priv.h ('k') | nss/lib/freebl/ecl/ecl_gf.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698