<!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=US-ASCII" http-equiv="Content-Type">
<title>
GitLab
</title>


<style>img {
max-width: 100%; height: auto;
}
body {
font-size: 0.875rem;
}
body {
-webkit-text-shadow: rgba(255,255,255,0.01) 0 0 1px;
}
body {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans", Ubuntu, Cantarell, "Helvetica Neue", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"; font-size: inherit;
}
</style>
</head>
<body style='font-size: inherit; -webkit-text-shadow: rgba(255,255,255,0.01) 0 0 1px; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans", Ubuntu, Cantarell, "Helvetica Neue", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";'>
<div class="content">

<p class="details" style="font-style: italic; color: #666;">
<a href="https://gitlab.com/richard.costa" style="color: #1068bf; text-decoration: none;">Richard Costa</a> created an issue: <a href="https://gitlab.com/gnutls/gnutls/-/issues/1364" style="color: #1068bf; text-decoration: none;">#1364</a>
</p>
<div class="md" style="color: #303030; word-wrap: break-word;">
<h2 dir="auto" style="font-size: 1.5em; font-weight: 600; padding-bottom: 0.3em; border-bottom-width: 1px; border-bottom-color: #eaeaea; border-bottom-style: solid; color: #303030; margin: 0 0 16px;" align="initial">
<a id="user-content-description-of-the-feature" class="anchor" href="#description-of-the-feature" aria-hidden="true" style="color: #1068bf; margin-top: 0; float: left; margin-left: -20px; text-decoration: none; outline: none;"></a>Description of the feature:</h2>
<p dir="auto" style="color: #303030; margin: 0 0 16px;" align="initial">One of the FIPS-140-3 requirements is the ability of a crypto module to execute integrity tests on-demand.
This can be done through a function which sets the FIPS state machine to the <code style='font-size: 90%; color: #1f1f1f; word-wrap: break-word; background-color: #f0f0f0; border-radius: 4px; margin-top: 0; font-weight: inherit; font-family: "Menlo", "DejaVu Sans Mono", "Liberation Mono", "Consolas", "Ubuntu Mono", "Courier New", "andale mono", "lucida console", monospace; white-space: pre-wrap; overflow-wrap: break-word; word-break: keep-all; padding: 2px 4px;'>LIB_STATE_SELFTEST</code>, executes the integrity tests on the appropriated modules and then sets the state to <code style='font-size: 90%; color: #1f1f1f; word-wrap: break-word; background-color: #f0f0f0; border-radius: 4px; font-weight: inherit; font-family: "Menlo", "DejaVu Sans Mono", "Liberation Mono", "Consolas", "Ubuntu Mono", "Courier New", "andale mono", "lucida console", monospace; white-space: pre-wrap; overflow-wrap: break-word; word-break: keep-all; padding: 2px 4px;'>LIB_STATE_OPERATIONAL</code> or <code style='font-size: 90%; color: #1f1f1f; word-wrap: break-word; background-color: #f0f0f0; border-radius: 4px; font-weight: inherit; font-family: "Menlo", "DejaVu Sans Mono", "Liberation Mono", "Consolas", "Ubuntu Mono", "Courier New", "andale mono", "lucida console", monospace; white-space: pre-wrap; overflow-wrap: break-word; word-break: keep-all; padding: 2px 4px;'>LIB_STATE_ERROR</code> based on the result.</p>
<p dir="auto" style="color: #303030; margin: 0 0 16px;" align="initial">The function <code style='font-size: 90%; color: #1f1f1f; word-wrap: break-word; background-color: #f0f0f0; border-radius: 4px; margin-top: 0; font-weight: inherit; font-family: "Menlo", "DejaVu Sans Mono", "Liberation Mono", "Consolas", "Ubuntu Mono", "Courier New", "andale mono", "lucida console", monospace; white-space: pre-wrap; overflow-wrap: break-word; word-break: keep-all; padding: 2px 4px;'>_gnutls_fips_perform_self_checks2</code> can be used as an example on how to execute the procedure described above.</p>
<p dir="auto" style="color: #303030; margin: 0 0 16px;" align="initial">The snippet below shows the interesting part:</p>
<div class="gl-relative markdown-code-block js-markdown-code">
<pre class="code highlight js-syntax-highlight language-plaintext" lang="plaintext" v-pre="true" style='display: block; font-size: 13px; color: #303030; line-height: 1.6em; overflow-x: auto; border-radius: 2px; position: relative; font-family: "Menlo", "DejaVu Sans Mono", "Liberation Mono", "Consolas", "Ubuntu Mono", "Courier New", "andale mono", "lucida console", monospace; word-break: break-all; word-wrap: break-word; background-color: #fafafa; margin: 0 0 16px; padding: 12px; border: 1px solid #dbdbdb;'><code style='font-size: inherit; color: inherit; word-wrap: normal; word-break: keep-all; background-color: inherit; border-radius: 4px; white-space: pre; margin-top: 0; font-family: "Menlo", "DejaVu Sans Mono", "Liberation Mono", "Consolas", "Ubuntu Mono", "Courier New", "andale mono", "lucida console", monospace; overflow-wrap: normal; padding: unset;'><span id="LC1" class="line" lang="plaintext" style="margin-top: 0;"> if (_skip_integrity_checks == 0) {</span>
<span id="LC2" class="line" lang="plaintext">                ret = check_binary_integrity(GNUTLS_LIBRARY_NAME, "gnutls_global_init");</span>
<span id="LC3" class="line" lang="plaintext">                if (ret == 0) {</span>
<span id="LC4" class="line" lang="plaintext">                        gnutls_assert();</span>
<span id="LC5" class="line" lang="plaintext">                        goto error;</span>
<span id="LC6" class="line" lang="plaintext">                }</span>
<span id="LC7" class="line" lang="plaintext"></span>
<span id="LC8" class="line" lang="plaintext">                ret = check_binary_integrity(NETTLE_LIBRARY_NAME, "nettle_aes_set_encrypt_key");</span>
<span id="LC9" class="line" lang="plaintext">                if (ret == 0) {</span>
<span id="LC10" class="line" lang="plaintext">                        gnutls_assert();</span>
<span id="LC11" class="line" lang="plaintext">                        goto error;</span>
<span id="LC12" class="line" lang="plaintext">                }</span>
<span id="LC13" class="line" lang="plaintext"></span>
<span id="LC14" class="line" lang="plaintext">                ret = check_binary_integrity(HOGWEED_LIBRARY_NAME, "nettle_mpz_sizeinbase_256_u");</span>
<span id="LC15" class="line" lang="plaintext">                if (ret == 0) {</span>
<span id="LC16" class="line" lang="plaintext">                        gnutls_assert();</span>
<span id="LC17" class="line" lang="plaintext">                        goto error;</span>
<span id="LC18" class="line" lang="plaintext">                }</span>
<span id="LC19" class="line" lang="plaintext"></span>
<span id="LC20" class="line" lang="plaintext">                ret = check_binary_integrity(GMP_LIBRARY_NAME, "__gmpz_init");</span>
<span id="LC21" class="line" lang="plaintext">                if (ret == 0) {</span>
<span id="LC22" class="line" lang="plaintext">                        gnutls_assert();</span>
<span id="LC23" class="line" lang="plaintext">                        goto error;</span>
<span id="LC24" class="line" lang="plaintext">                }</span>
<span id="LC25" class="line" lang="plaintext">        }</span>
<span id="LC26" class="line" lang="plaintext"></span>
<span id="LC27" class="line" lang="plaintext">        return 0;</span>
<span id="LC28" class="line" lang="plaintext"></span>
<span id="LC29" class="line" lang="plaintext">error:</span>
<span id="LC30" class="line" lang="plaintext">        _gnutls_switch_lib_state(LIB_STATE_ERROR);</span></code></pre>
<copy-code></copy-code>
</div>
<h2 dir="auto" style="font-size: 1.5em; font-weight: 600; padding-bottom: 0.3em; border-bottom-width: 1px; border-bottom-color: #eaeaea; border-bottom-style: solid; color: #303030; margin: 24px 0 16px;" align="initial">
<a id="user-content-applications-that-this-feature-may-be-relevant-to" class="anchor" href="#applications-that-this-feature-may-be-relevant-to" aria-hidden="true" style="color: #1068bf; margin-top: 0; float: left; margin-left: -20px; text-decoration: none; outline: none;"></a>Applications that this feature may be relevant to:</h2>
<p dir="auto" style="color: #303030; margin: 0 0 16px;" align="initial">Any application which requires a FIPS-140-3 compliant library.</p>
<h2 dir="auto" style="font-size: 1.5em; font-weight: 600; padding-bottom: 0.3em; border-bottom-width: 1px; border-bottom-color: #eaeaea; border-bottom-style: solid; color: #303030; margin: 24px 0 16px;" align="initial">
<a id="user-content-is-this-feature-implemented-in-other-libraries-and-which" class="anchor" href="#is-this-feature-implemented-in-other-libraries-and-which" aria-hidden="true" style="color: #1068bf; margin-top: 0; float: left; margin-left: -20px; text-decoration: none; outline: none;"></a>Is this feature implemented in other libraries (and which)</h2>
<p dir="auto" style="color: #303030; margin: 0;" align="initial">libgcrypt and openssl</p>
</div>

</div>
<div class="footer" style="margin-top: 10px;">
<p style="font-size: small; color: #666;">

<br>
Reply to this email directly or <a href="https://gitlab.com/gnutls/gnutls/-/issues/1364" style="color: #1068bf; text-decoration: none;">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/15411e0d5d524300d6f550528734ae94/unsubscribe" style="color: #1068bf; text-decoration: none;">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/1364"}}</script>


</p>
</div>
</body>
</html>