blob: 3be30408cadc651e4b120449f60bba24662719ad [file] [log] [blame]
Gilles Peskine882f7c72022-04-07 13:44:55 +02001
2<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
3 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
4
5<html xmlns="http://www.w3.org/1999/xhtml">
6 <head>
7 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
8 <title>10.10. Other cryptographic services &#8212; PSA Crypto API 1.1.0 documentation</title>
9 <link rel="stylesheet" href="../../_static/alabaster.css" type="text/css" />
10 <link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
11 <script type="text/javascript">
12 var DOCUMENTATION_OPTIONS = {
13 URL_ROOT: '../../',
14 VERSION: '1.1.0',
15 COLLAPSE_INDEX: false,
16 FILE_SUFFIX: '.html',
17 HAS_SOURCE: false,
18 SOURCELINK_SUFFIX: '.txt'
19 };
20 </script>
21 <script type="text/javascript" src="../../_static/jquery.js"></script>
22 <script type="text/javascript" src="../../_static/underscore.js"></script>
23 <script type="text/javascript" src="../../_static/doctools.js"></script>
24 <link rel="author" title="About these documents" href="../../about.html" />
25 <link rel="index" title="Index" href="../../genindex.html" />
26 <link rel="search" title="Search" href="../../search.html" />
27 <link rel="next" title="Example header file" href="../../appendix/example_header.html" />
28 <link rel="prev" title="10.9. Key agreement" href="ka.html" />
29
30 <link rel="stylesheet" href="../../_static/custom.css" type="text/css" />
31
32 <meta name="viewport" content="width=device-width, initial-scale=0.9, maximum-scale=0.9" />
33
34 </head>
35 <body>
36
37
38 <div class="document">
39 <div class="documentwrapper">
40 <div class="bodywrapper">
41 <div class="body" role="main">
42
43 <div class="section" id="other-cryptographic-services">
44<h1>10.10. Other cryptographic services</h1>
45<div class="section" id="random-number-generation">
46<span id="rng"></span><h2>10.10.1. Random number generation</h2>
47<div class="section" id="psa_generate_random">
48<span id="c.psa_generate_random"></span><h3><code class="docutils literal"><span class="pre">psa_generate_random</span></code> (function)</h3>
49<p>Generate random bytes.</p>
50<pre class="literal-block">
51<a class="reference internal" href="../library/status.html#c.psa_status_t" title="psa_status_t">psa_status_t</a> <a class="reference internal" href="#c.psa_generate_random" title="psa_generate_random">psa_generate_random</a>(uint8_t * output,
52 size_t output_size);
53</pre>
54<p class="rubric">Parameters</p>
55<dl class="docutils">
56<dt> <code class="docutils literal"><span class="pre">output</span></code></dt>
57<dd>Output buffer for the generated data.</dd>
58<dt> <code class="docutils literal"><span class="pre">output_size</span></code></dt>
59<dd>Number of bytes to generate and output.</dd>
60</dl>
61<p class="rubric">Returns: <a class="reference internal" href="../library/status.html#c.psa_status_t" title="psa_status_t"><code class="docutils literal"><span class="pre">psa_status_t</span></code></a></p>
62<dl class="docutils">
63<dt> <a class="reference internal" href="../library/status.html#c.PSA_SUCCESS" title="PSA_SUCCESS"><code class="docutils literal"><span class="pre">PSA_SUCCESS</span></code></a></dt>
64<dd>Success.
65<code class="docutils literal"><span class="pre">output</span></code> contains <code class="docutils literal"><span class="pre">output_size</span></code> bytes of generated random data.</dd>
66<dt> <a class="reference internal" href="../library/status.html#c.PSA_ERROR_BAD_STATE" title="PSA_ERROR_BAD_STATE"><code class="docutils literal"><span class="pre">PSA_ERROR_BAD_STATE</span></code></a></dt>
67<dd>The library requires initializing by a call to <a class="reference internal" href="../library/library.html#c.psa_crypto_init" title="psa_crypto_init"><code class="xref any c c-func docutils literal"><span class="pre">psa_crypto_init()</span></code></a>.</dd>
68<dt> <a class="reference internal" href="../library/status.html#c.PSA_ERROR_NOT_SUPPORTED" title="PSA_ERROR_NOT_SUPPORTED"><code class="docutils literal"><span class="pre">PSA_ERROR_NOT_SUPPORTED</span></code></a></dt>
69<dd></dd>
70<dt> <a class="reference internal" href="../library/status.html#c.PSA_ERROR_INSUFFICIENT_ENTROPY" title="PSA_ERROR_INSUFFICIENT_ENTROPY"><code class="docutils literal"><span class="pre">PSA_ERROR_INSUFFICIENT_ENTROPY</span></code></a></dt>
71<dd></dd>
72<dt> <a class="reference internal" href="../library/status.html#c.PSA_ERROR_INSUFFICIENT_MEMORY" title="PSA_ERROR_INSUFFICIENT_MEMORY"><code class="docutils literal"><span class="pre">PSA_ERROR_INSUFFICIENT_MEMORY</span></code></a></dt>
73<dd></dd>
74<dt> <a class="reference internal" href="../library/status.html#c.PSA_ERROR_COMMUNICATION_FAILURE" title="PSA_ERROR_COMMUNICATION_FAILURE"><code class="docutils literal"><span class="pre">PSA_ERROR_COMMUNICATION_FAILURE</span></code></a></dt>
75<dd></dd>
76<dt> <a class="reference internal" href="../library/status.html#c.PSA_ERROR_CORRUPTION_DETECTED" title="PSA_ERROR_CORRUPTION_DETECTED"><code class="docutils literal"><span class="pre">PSA_ERROR_CORRUPTION_DETECTED</span></code></a></dt>
77<dd></dd>
78</dl>
79<p class="rubric">Description</p>
80<div class="admonition warning">
81<p class="first admonition-title">Warning</p>
82<p class="last">This function <strong>can</strong> fail! Callers MUST check the return status and MUST NOT use the content of the output buffer if the return status is not <a class="reference internal" href="../library/status.html#c.PSA_SUCCESS" title="PSA_SUCCESS"><code class="xref any c c-macro docutils literal"><span class="pre">PSA_SUCCESS</span></code></a>.</p>
83</div>
84<div class="admonition note">
85<p class="first admonition-title">Note</p>
86<p class="last">To generate a key, use <a class="reference internal" href="../keys/management.html#c.psa_generate_key" title="psa_generate_key"><code class="xref any c c-func docutils literal"><span class="pre">psa_generate_key()</span></code></a> instead.</p>
87</div>
88</div>
89</div>
90</div>
91
92
93 </div>
94 </div>
95 </div>
96 <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
97 <div class="sphinxsidebarwrapper"><h3><a href="../../index.html"><b>PSA Crypto API</b></a></h3>
98IHI 0086<br/>
99Non-confidential<br/>
100Version 1.1.0
101<span style="color: red; font-weight: bold;"></span>
102<ul>
103<li class="toctree-l1"><a class="reference internal" href="../../about.html">About this document</a></li>
104</ul>
105<ul class="current">
106<li class="toctree-l1"><a class="reference internal" href="../../overview/intro.html">1. Introduction</a></li>
107<li class="toctree-l1"><a class="reference internal" href="../../overview/goals.html">2. Design goals</a></li>
108<li class="toctree-l1"><a class="reference internal" href="../../overview/functionality.html">3. Functionality overview</a></li>
109<li class="toctree-l1"><a class="reference internal" href="../../overview/sample-arch.html">4. Sample architectures</a></li>
110<li class="toctree-l1"><a class="reference internal" href="../../overview/conventions.html">5. Library conventions</a></li>
111<li class="toctree-l1"><a class="reference internal" href="../../overview/implementation.html">6. Implementation considerations</a></li>
112<li class="toctree-l1"><a class="reference internal" href="../../overview/usage.html">7. Usage considerations</a></li>
113<li class="toctree-l1"><a class="reference internal" href="../library/index.html">8. Library management reference</a></li>
114<li class="toctree-l1"><a class="reference internal" href="../keys/index.html">9. Key management reference</a></li>
115<li class="toctree-l1 current"><a class="reference internal" href="index.html">10. Cryptographic operation reference</a><ul class="current">
116<li class="toctree-l2"><a class="reference internal" href="algorithms.html">10.1. Algorithms</a></li>
117<li class="toctree-l2"><a class="reference internal" href="hashes.html">10.2. Message digests (Hashes)</a></li>
118<li class="toctree-l2"><a class="reference internal" href="macs.html">10.3. Message authentication codes (MAC)</a></li>
119<li class="toctree-l2"><a class="reference internal" href="ciphers.html">10.4. Unauthenticated ciphers</a></li>
120<li class="toctree-l2"><a class="reference internal" href="aead.html">10.5. Authenticated encryption with associated data (AEAD)</a></li>
121<li class="toctree-l2"><a class="reference internal" href="kdf.html">10.6. Key derivation</a></li>
122<li class="toctree-l2"><a class="reference internal" href="sign.html">10.7. Asymmetric signature</a></li>
123<li class="toctree-l2"><a class="reference internal" href="pke.html">10.8. Asymmetric encryption</a></li>
124<li class="toctree-l2"><a class="reference internal" href="ka.html">10.9. Key agreement</a></li>
125<li class="toctree-l2 current"><a class="current reference internal" href="#">10.10. Other cryptographic services</a><ul>
126<li class="toctree-l3"><a class="reference internal" href="#random-number-generation">10.10.1. Random number generation</a></li>
127</ul>
128</li>
129</ul>
130</li>
131</ul>
132<ul>
133<li class="toctree-l1"><a class="reference internal" href="../../appendix/example_header.html">Example header file</a></li>
134<li class="toctree-l1"><a class="reference internal" href="../../appendix/encodings.html">Algorithm and key type encoding</a></li>
135<li class="toctree-l1"><a class="reference internal" href="../../appendix/specdef_values.html">Example macro implementations</a></li>
136<li class="toctree-l1"><a class="reference internal" href="../../appendix/sra.html">Security Risk Assessment</a></li>
137<li class="toctree-l1"><a class="reference internal" href="../../appendix/history.html">Changes to the API</a></li>
138</ul>
139<ul>
140<li class="toctree-l1"><a class="reference internal" href="../../psa_c-identifiers.html">Index of API elements</a></li>
141</ul>
142<div id="searchbox" style="display: none" role="search">
143 <h3>Quick search</h3>
144 <form class="search" action="../../search.html" method="get">
145 <div><input type="text" name="q" /></div>
146 <div><input type="submit" value="Go" /></div>
147 <input type="hidden" name="check_keywords" value="yes" />
148 <input type="hidden" name="area" value="default" />
149 </form>
150</div>
151<script type="text/javascript">$('#searchbox').show(0);</script>
152 </div>
153 </div>
154 <div class="clearer"></div>
155 </div>
156 <div class="footer">
157 &copy; 2018-2022, Arm Limited or its affiliates. All rights reserved.
158
159 |
160 Powered by <a href="http://sphinx-doc.org/">Sphinx 1.6.7</a>
161 &amp; <a href="https://github.com/bitprophet/alabaster">Alabaster 0.7.8</a>
162
163 </div>
164
165
166
167
168 </body>
169</html>