0x02, 0x02, 0x1e, 0x01, 0x03, 0x43, 0x00, 0x04, 0x40};
unsigned char encoded[37+64];
const unsigned char* pp;
- if(keylen != 64) {
+ if(keylen != 66) {
/* key wrong size */
return NULL;
}
+ if(key[0] != 0 || key[1] != 0) {
+ /* unsupported GOST algo or digest paramset */
+ return NULL;
+ }
/* create evp_key */
memmove(encoded, asn, 37);
- memmove(encoded+37, key, 64);
+ memmove(encoded+37, key+2, 64);
pp = (unsigned char*)&encoded[0];
return d2i_PUBKEY(NULL, &pp, sizeof(encoded));
ldns_rdf *b64_bignum;
ldns_status status;
+ ldns_buffer_printf(output, "GostAsn1: ");
+
ret = i2d_PrivateKey(p, &pp);
b64_bignum = ldns_rdf_new_frm_data(LDNS_RDF_TYPE_B64, ret, pp);
status = ldns_rdf2buffer_str(output, b64_bignum);
/* no format defined, use blob */
#if defined(HAVE_SSL) && defined(USE_GOST)
ldns_buffer_printf(output, "Private-key-format: v1.2\n");
- ldns_buffer_printf(output, "Algorithm: 211 (GOST)\n");
+ ldns_buffer_printf(output, "Algorithm: %d (GOST)\n", LDNS_SIGN_GOST);
status = ldns_gost_key2buffer_str(output, k->_key.key);
#endif
break;
static EVP_PKEY*
ldns_key_new_frm_fp_gost_l(FILE* fp, int* line_nr)
{
- ssize_t len;
char token[16384];
const unsigned char* pp;
int gost_id;
if(!gost_id)
return NULL;
- len = ldns_fget_token_l(fp, token, "", sizeof(token), line_nr);
- if(len == -1)
+ if (ldns_fget_keyword_data_l(fp, "GostAsn1", ": ", token, "\n",
+ sizeof(token), line_nr) == -1)
return NULL;
+ while(strlen(token) < 96) {
+ /* read more b64 from the file, b64 split on multiple lines */
+ if(ldns_fget_token_l(fp, token+strlen(token), "\n",
+ sizeof(token)-strlen(token), line_nr) == -1)
+ return NULL;
+ }
if(ldns_str2rdf_b64(&b64rdf, token) != LDNS_STATUS_OK)
return NULL;
pp = (unsigned char*)ldns_rdf_data(b64rdf);
fprintf(stderr, "version of ldns\n");
#endif
}
- if (strncmp(d, "211 GOST", 4) == 0) {
+ if (strncmp(d, "249 GOST", 4) == 0) {
#ifdef USE_GOST
alg = LDNS_SIGN_GOST;
#else
return false;
}
/* omit ASN header */
+ /* insert parameters */
+ data[0] = 0;
+ data[1] = 0;
for(i=0; i<64; i++)
- data[i] = pp[i+37];
+ data[i+2] = pp[i+37];
CRYPTO_free(pp);
- *size = 64;
+ *size = 66;
return true;
}
#endif /* USE_GOST */
LDNS_RSASHA1_NSEC3 = 7,
LDNS_RSASHA256 = 8, /* RFC 5702 */
LDNS_RSASHA512 = 10, /* RFC 5702 */
- LDNS_GOST = 211, /* not official */
+ LDNS_GOST = 249, /* not official */
LDNS_INDIRECT = 252,
LDNS_PRIVATEDNS = 253,
LDNS_PRIVATEOID = 254