aboutsummaryrefslogtreecommitdiff
path: root/files/sv-se/web/api/subtlecrypto/index.html
blob: 881c36812ce7ac3990e283843bbc263eeee72864 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
---
title: SubtleCrypto
slug: Web/API/SubtleCrypto
tags:
  - API
  - Interface
  - NeedsTranslation
  - Reference
  - TopicStub
  - Web Crypto API
translation_of: Web/API/SubtleCrypto
---
<p>{{APIRef("Web Crypto API")}}</p>

<p>The <code><strong>SubtleCrypto</strong></code> interface represents a set of cryptographic primitives. It is available via the {{domxref("Crypto.subtle")}} properties available in a window context (via {{domxref("Window.crypto")}}).</p>

<div class="warning">
<p>Per the spec: "Developers making use of the SubtleCrypto interface are expected to be aware of the security concerns associated with both the design and implementation of the various algorithms provided. The raw algorithms are provided in order to allow developers maximum flexibility in implementing a variety of protocols and applications, each of which may represent the composition and security parameters in a unique manner that necessitate the use of the raw algorithms."</p>
</div>

<h2 id="Properties">Properties</h2>

<p><em>This interface neither inherits, nor implements, any property.</em></p>

<h2 id="Methods">Methods</h2>

<p>This interface doesn't inherit any method.</p>

<dl>
 <dt>{{domxref("SubtleCrypto.encrypt()")}}</dt>
 <dd>Returns a {{jsxref("Promise")}} of the encrypted data corresponding to the clear text, algorithm and key given as parameters.</dd>
 <dt>{{domxref("SubtleCrypto.decrypt()")}}</dt>
 <dd>Returns a {{jsxref("Promise")}} of the clear data corresponding to the encrypted text, algorithm and key given as parameters.</dd>
 <dt>{{domxref("SubtleCrypto.sign()")}}</dt>
 <dd>Returns a {{jsxref("Promise")}} of the signature corresponding to the text, algorithm and key given as parameters.</dd>
 <dt>{{domxref("SubtleCrypto.verify()")}}</dt>
 <dd>Returns a {{jsxref("Promise")}} of a {{jsxref("Boolean")}} value indicating if the signature given as parameter matches the text, algorithm and key also given as parameters.</dd>
 <dt>{{domxref("SubtleCrypto.digest()")}}</dt>
 <dd>Returns a {{jsxref("Promise")}} of a digest generated from the algorithm and text given as parameters.</dd>
 <dt>{{domxref("SubtleCrypto.generateKey()")}}</dt>
 <dd>Returns a {{jsxref("Promise")}} of a newly generated {{domxref("CryptoKey")}}, for symmetrical algorithms, or a {{domxref("CryptoKeyPair")}}, containing two newly generated keys, for asymmetrical algorithm, that matches the algorithm, the usages and the extractability given as parameters.</dd>
 <dt>{{domxref("SubtleCrypto.deriveKey()")}}</dt>
 <dd>Returns a {{jsxref("Promise")}} of a newly generated {{domxref("CryptoKey")}} derived from a master key and a specific algorithm given as parameters.</dd>
 <dt>{{domxref("SubtleCrypto.deriveBits()")}}</dt>
 <dd>Returns a {{jsxref("Promise")}} of a newly generated buffer of pseudo-random bits derived from a master key and a specific algorithm given as parameters.</dd>
 <dt>{{domxref("SubtleCrypto.importKey()")}}</dt>
 <dd>Returns a {{jsxref("Promise")}} of a {{domxref("CryptoKey")}} corresponding to the format, the algorithm, the raw key data, the usages and the extractability given as parameters.</dd>
 <dt>{{domxref("SubtleCrypto.exportKey()")}}</dt>
 <dd>Returns a {{jsxref("Promise")}} of a buffer containing the key in the format requested.</dd>
 <dt>{{domxref("SubtleCrypto.wrapKey()")}}</dt>
 <dd>Returns a {{jsxref("Promise")}} of a wrapped symmetric key for usage (transfer, storage) in insecure environments. The wrapped buffer returned is in the format given in parameters, and contains the key wrapped by the given wrapping key with the given algorithm.</dd>
 <dt>{{domxref("SubtleCrypto.unwrapKey()")}}</dt>
 <dd>Returns a {{jsxref("Promise")}} of a {{domxref("CryptoKey")}} corresponding to the wrapped key given in parameter.</dd>
</dl>

<h2 id="Specifications">Specifications</h2>

<table class="standard-table">
 <tbody>
  <tr>
   <th scope="col">Specification</th>
   <th scope="col">Status</th>
   <th scope="col">Comment</th>
  </tr>
  <tr>
   <td>{{ SpecName('Web Crypto API', '#subtlecrypto-interface', 'SubtleCrypto') }}</td>
   <td>{{ Spec2('Web Crypto API') }}</td>
   <td>Initial definition.</td>
  </tr>
 </tbody>
</table>

<h2 id="Browser_compatibility">Browser compatibility</h2>



<p>{{Compat("api.SubtleCrypto")}}</p>

<h2 id="See_also">See also</h2>

<ul>
 <li>{{domxref("Crypto")}} and {{domxref("Crypto.subtle")}}.</li>
</ul>