<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<html lang="en">
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<title>
GitLab
</title>
<style>img {
max-width: 100%; height: auto;
}
</style>
</head>
<body>
<div class="content">
<div>
<pre class="code highlight js-syntax-highlight plaintext" lang="plaintext" v-pre="true"><code><span id="LC1" class="line" lang="plaintext"> gnutls_ecc_curve_t curve = GNUTLS_ECC_CURVE_SECP256R1;</span>
<span id="LC2" class="line" lang="plaintext"></span>
<span id="LC3" class="line" lang="plaintext"> uint8_t x_data[] = {</span>
<span id="LC4" class="line" lang="plaintext"> 0xdd, 0x3b, 0xe9, 0x90, 0x9e, 0xb8, 0x2b, 0x36, 0x49, 0xa0, 0x0c, 0xc0, 0x30, 0x46, 0x97, 0x13,</span>
<span id="LC5" class="line" lang="plaintext"> 0xdc, 0x77, 0x7b, 0xd5, 0xdf, 0xe2, 0x6b, 0x3d, 0xbd, 0xc5, 0x37, 0x23, 0xde, 0x12, 0xac, 0x97</span>
<span id="LC6" class="line" lang="plaintext"> };</span>
<span id="LC7" class="line" lang="plaintext"> gnutls_datum_t x = { .size = sizeof(x_data), .data = x_data };</span>
<span id="LC8" class="line" lang="plaintext"></span>
<span id="LC9" class="line" lang="plaintext"> uint8_t y_data[] = {</span>
<span id="LC10" class="line" lang="plaintext"> 0x54, 0xa2, 0x67, 0xe9, 0x59, 0xd0, 0xec, 0xa2, 0xcc, 0x34, 0x1b, 0xe6, 0x6b, 0x14, 0x6a, 0xdf,</span>
<span id="LC11" class="line" lang="plaintext"> 0xc3, 0xb4, 0x6c, 0x73, 0x0a, 0x1c, 0x1c, 0x5f, 0xde, 0x48, 0x6c, 0x47, 0x5e, 0x84, 0xf1, 0x75</span>
<span id="LC12" class="line" lang="plaintext"> };</span>
<span id="LC13" class="line" lang="plaintext"> gnutls_datum_t y = { .size = sizeof(y_data), .data = y_data };</span>
<span id="LC14" class="line" lang="plaintext"></span>
<span id="LC15" class="line" lang="plaintext"> uint8_t priv_key[] = {</span>
<span id="LC16" class="line" lang="plaintext"> 0x28, 0xbd, 0xc1, 0xed, 0xed, 0xcd, 0x23, 0xdb, 0x6b, 0x69, 0x34, 0x94, 0xcb, 0xd9, 0xc6, 0xb5,</span>
<span id="LC17" class="line" lang="plaintext"> 0xb7, 0x9d, 0xb5, 0x37, 0x3b, 0xe2, 0x04, 0xea, 0x0a, 0x05, 0xfd, 0xd0, 0x8c, 0x20, 0xd8, 0x9c };</span>
<span id="LC18" class="line" lang="plaintext"> gnutls_datum_t k = { .size = sizeof(priv_key), .data = priv_key };</span>
<span id="LC19" class="line" lang="plaintext"></span>
<span id="LC20" class="line" lang="plaintext"> gnutls_x509_privkey_t key = NULL;</span>
<span id="LC21" class="line" lang="plaintext"> int result = gnutls_x509_privkey_init(&key);</span>
<span id="LC22" class="line" lang="plaintext"> assert(result == GNUTLS_E_SUCCESS);</span>
<span id="LC23" class="line" lang="plaintext"></span>
<span id="LC24" class="line" lang="plaintext"> result = gnutls_x509_privkey_import_ecc_raw(key, curve, &x, &y, &k);</span>
<span id="LC25" class="line" lang="plaintext"> assert(result == GNUTLS_E_SUCCESS);</span>
<span id="LC26" class="line" lang="plaintext"></span>
<span id="LC27" class="line" lang="plaintext"> gnutls_x509_privkey_fix(key);</span>
<span id="LC28" class="line" lang="plaintext"> assert(result == GNUTLS_E_SUCCESS);</span>
<span id="LC29" class="line" lang="plaintext"></span>
<span id="LC30" class="line" lang="plaintext"> gnutls_x509_crt_fmt_t format = GNUTLS_X509_FMT_PEM;</span>
<span id="LC31" class="line" lang="plaintext"> char *password = NULL;</span>
<span id="LC32" class="line" lang="plaintext"> int flags = GNUTLS_PKCS_PLAIN;</span>
<span id="LC33" class="line" lang="plaintext"></span>
<span id="LC34" class="line" lang="plaintext"> uint8_t out_data[4096];</span>
<span id="LC35" class="line" lang="plaintext"> size_t out_size = 4096;</span>
<span id="LC36" class="line" lang="plaintext"> result = gnutls_x509_privkey_export_pkcs8(key, format, password, flags,</span>
<span id="LC37" class="line" lang="plaintext"> out_data, &out_size);</span>
<span id="LC38" class="line" lang="plaintext"> assert(result == GNUTLS_E_SUCCESS);</span>
<span id="LC39" class="line" lang="plaintext"></span>
<span id="LC40" class="line" lang="plaintext"> gnutls_x509_privkey_deinit(key);</span></code></pre>
</div>
</div>
<div class="footer" style="margin-top: 10px;">
<p style="font-size: small; color: #777;">
—
<br>
Reply to this email directly or
<a href="https://gitlab.com/gnutls/gnutls/issues/516#note_88235177">view it on GitLab</a>.
<br>
You're receiving this email because of your account on gitlab.com.
If you'd like to receive fewer emails, you can
<a href="https://gitlab.com/sent_notifications/11edb4e0d9d5e4acf508ef4b6a751684/unsubscribe">unsubscribe</a>
from this thread or
adjust your notification settings.
<script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","action":{"@type":"ViewAction","name":"View Issue","url":"https://gitlab.com/gnutls/gnutls/issues/516#note_88235177"}}</script>
</p>
</div>
</body>
</html>