102 i++;
103 }
104
105 return item;
106 }
107
108 static SECStatus
109 gf_populate_params(ECCurveName name, ECFieldType field_type, ECParams *params,
110 int kmflag)
111 {
112 SECStatus rv = SECFailure;
113 const ECCurveParams *curveParams;
114 /* 2 ['0'+'4'] + MAX_ECKEY_LEN * 2 [x,y] * 2 [hex string] + 1 ['\0'] */
115 char genenc[3 + 2 * 2 * MAX_ECKEY_LEN];
116
117 if (((int)name < ECCurve_noName) || (name > ECCurve_pastLastCurve))
118 goto cleanup;
119 params->name = name;
120 curveParams = ecCurve_map[params->name];
121 CHECK_OK(curveParams);
122 params->fieldID.size = curveParams->size;
123 params->fieldID.type = field_type;
124 if (field_type == ec_field_GFp) {
125 CHECK_OK(hexString2SECItem(NULL, ¶ms->fieldID.u.prime,
126 curveParams->irr, kmflag));
127 } else {
128 CHECK_OK(hexString2SECItem(NULL, ¶ms->fieldID.u.poly,
129 curveParams->irr, kmflag));
130 }
131 CHECK_OK(hexString2SECItem(NULL, ¶ms->curve.a,
132 curveParams->curvea, kmflag));
133 CHECK_OK(hexString2SECItem(NULL, ¶ms->curve.b,
134 curveParams->curveb, kmflag));
135 genenc[0] = '0';
136 genenc[1] = '4';
137 genenc[2] = '\0';
138 strcat(genenc, curveParams->genx);
139 strcat(genenc, curveParams->geny);
140 CHECK_OK(hexString2SECItem(NULL, ¶ms->base, genenc, kmflag));
141 CHECK_OK(hexString2SECItem(NULL, ¶ms->order,
|
102 i++;
103 }
104
105 return item;
106 }
107
108 static SECStatus
109 gf_populate_params(ECCurveName name, ECFieldType field_type, ECParams *params,
110 int kmflag)
111 {
112 SECStatus rv = SECFailure;
113 const ECCurveParams *curveParams;
114 /* 2 ['0'+'4'] + MAX_ECKEY_LEN * 2 [x,y] * 2 [hex string] + 1 ['\0'] */
115 char genenc[3 + 2 * 2 * MAX_ECKEY_LEN];
116
117 if (((int)name < ECCurve_noName) || (name > ECCurve_pastLastCurve))
118 goto cleanup;
119 params->name = name;
120 curveParams = ecCurve_map[params->name];
121 CHECK_OK(curveParams);
122 if ((strlen(curveParams->genx) + strlen(curveParams->geny)) > 2 * 2 * MAX_ECKEY_LEN) {
123 goto cleanup;
124 }
125 params->fieldID.size = curveParams->size;
126 params->fieldID.type = field_type;
127 if (field_type == ec_field_GFp) {
128 CHECK_OK(hexString2SECItem(NULL, ¶ms->fieldID.u.prime,
129 curveParams->irr, kmflag));
130 } else {
131 CHECK_OK(hexString2SECItem(NULL, ¶ms->fieldID.u.poly,
132 curveParams->irr, kmflag));
133 }
134 CHECK_OK(hexString2SECItem(NULL, ¶ms->curve.a,
135 curveParams->curvea, kmflag));
136 CHECK_OK(hexString2SECItem(NULL, ¶ms->curve.b,
137 curveParams->curveb, kmflag));
138 genenc[0] = '0';
139 genenc[1] = '4';
140 genenc[2] = '\0';
141 strcat(genenc, curveParams->genx);
142 strcat(genenc, curveParams->geny);
143 CHECK_OK(hexString2SECItem(NULL, ¶ms->base, genenc, kmflag));
144 CHECK_OK(hexString2SECItem(NULL, ¶ms->order,
|