webcrypto.idl (6065B)
1 // GENERATED CONTENT - DO NOT EDIT 2 // Content was automatically extracted by Reffy into webref 3 // (https://github.com/w3c/webref) 4 // Source: Web Cryptography API Level 2 (https://w3c.github.io/webcrypto/) 5 6 partial interface mixin WindowOrWorkerGlobalScope { 7 [SameObject] readonly attribute Crypto crypto; 8 }; 9 10 [Exposed=(Window,Worker)] 11 interface Crypto { 12 [SecureContext] readonly attribute SubtleCrypto subtle; 13 ArrayBufferView getRandomValues(ArrayBufferView array); 14 [SecureContext] DOMString randomUUID(); 15 }; 16 17 typedef (object or DOMString) AlgorithmIdentifier; 18 19 typedef AlgorithmIdentifier HashAlgorithmIdentifier; 20 21 dictionary Algorithm { 22 required DOMString name; 23 }; 24 25 dictionary KeyAlgorithm { 26 required DOMString name; 27 }; 28 29 enum KeyType { "public", "private", "secret" }; 30 31 [SecureContext,Exposed=(Window,Worker),Serializable] 32 interface CryptoKey { 33 readonly attribute KeyType type; 34 readonly attribute boolean extractable; 35 readonly attribute object algorithm; 36 readonly attribute object usages; 37 }; 38 39 [SecureContext,Exposed=(Window,Worker)] 40 interface SubtleCrypto { 41 Promise<ArrayBuffer> encrypt( 42 AlgorithmIdentifier algorithm, 43 CryptoKey key, 44 BufferSource data 45 ); 46 Promise<ArrayBuffer> decrypt( 47 AlgorithmIdentifier algorithm, 48 CryptoKey key, 49 BufferSource data 50 ); 51 Promise<ArrayBuffer> sign( 52 AlgorithmIdentifier algorithm, 53 CryptoKey key, 54 BufferSource data 55 ); 56 Promise<boolean> verify( 57 AlgorithmIdentifier algorithm, 58 CryptoKey key, 59 BufferSource signature, 60 BufferSource data 61 ); 62 Promise<ArrayBuffer> digest( 63 AlgorithmIdentifier algorithm, 64 BufferSource data 65 ); 66 67 Promise<(CryptoKey or CryptoKeyPair)> generateKey( 68 AlgorithmIdentifier algorithm, 69 boolean extractable, 70 sequence<KeyUsage> keyUsages 71 ); 72 Promise<CryptoKey> deriveKey( 73 AlgorithmIdentifier algorithm, 74 CryptoKey baseKey, 75 AlgorithmIdentifier derivedKeyType, 76 boolean extractable, 77 sequence<KeyUsage> keyUsages 78 ); 79 Promise<ArrayBuffer> deriveBits( 80 AlgorithmIdentifier algorithm, 81 CryptoKey baseKey, 82 optional unsigned long? length = null 83 ); 84 85 Promise<CryptoKey> importKey( 86 KeyFormat format, 87 (BufferSource or JsonWebKey) keyData, 88 AlgorithmIdentifier algorithm, 89 boolean extractable, 90 sequence<KeyUsage> keyUsages 91 ); 92 Promise<(ArrayBuffer or JsonWebKey)> exportKey( 93 KeyFormat format, 94 CryptoKey key 95 ); 96 97 Promise<ArrayBuffer> wrapKey( 98 KeyFormat format, 99 CryptoKey key, 100 CryptoKey wrappingKey, 101 AlgorithmIdentifier wrapAlgorithm 102 ); 103 Promise<CryptoKey> unwrapKey( 104 KeyFormat format, 105 BufferSource wrappedKey, 106 CryptoKey unwrappingKey, 107 AlgorithmIdentifier unwrapAlgorithm, 108 AlgorithmIdentifier unwrappedKeyAlgorithm, 109 boolean extractable, 110 sequence<KeyUsage> keyUsages 111 ); 112 }; 113 114 dictionary RsaOtherPrimesInfo { 115 // The following fields are defined in Section 6.3.2.7 of JSON Web Algorithms 116 DOMString r; 117 DOMString d; 118 DOMString t; 119 }; 120 121 dictionary JsonWebKey { 122 // The following fields are defined in Section 3.1 of JSON Web Key 123 DOMString kty; 124 DOMString use; 125 sequence<DOMString> key_ops; 126 DOMString alg; 127 128 // The following fields are defined in JSON Web Key Parameters Registration 129 boolean ext; 130 131 // The following fields are defined in Section 6 of JSON Web Algorithms 132 DOMString crv; 133 DOMString x; 134 DOMString y; 135 DOMString d; 136 DOMString n; 137 DOMString e; 138 DOMString p; 139 DOMString q; 140 DOMString dp; 141 DOMString dq; 142 DOMString qi; 143 sequence<RsaOtherPrimesInfo> oth; 144 DOMString k; 145 }; 146 147 typedef Uint8Array BigInteger; 148 149 dictionary CryptoKeyPair { 150 CryptoKey publicKey; 151 CryptoKey privateKey; 152 }; 153 154 dictionary RsaKeyGenParams : Algorithm { 155 required [EnforceRange] unsigned long modulusLength; 156 required BigInteger publicExponent; 157 }; 158 159 dictionary RsaHashedKeyGenParams : RsaKeyGenParams { 160 required HashAlgorithmIdentifier hash; 161 }; 162 163 dictionary RsaKeyAlgorithm : KeyAlgorithm { 164 required unsigned long modulusLength; 165 required BigInteger publicExponent; 166 }; 167 168 dictionary RsaHashedKeyAlgorithm : RsaKeyAlgorithm { 169 required KeyAlgorithm hash; 170 }; 171 172 dictionary RsaHashedImportParams : Algorithm { 173 required HashAlgorithmIdentifier hash; 174 }; 175 176 dictionary RsaPssParams : Algorithm { 177 required [EnforceRange] unsigned long saltLength; 178 }; 179 180 dictionary RsaOaepParams : Algorithm { 181 BufferSource label; 182 }; 183 184 dictionary EcdsaParams : Algorithm { 185 required HashAlgorithmIdentifier hash; 186 }; 187 188 typedef DOMString NamedCurve; 189 190 dictionary EcKeyGenParams : Algorithm { 191 required NamedCurve namedCurve; 192 }; 193 194 dictionary EcKeyAlgorithm : KeyAlgorithm { 195 required NamedCurve namedCurve; 196 }; 197 198 dictionary EcKeyImportParams : Algorithm { 199 required NamedCurve namedCurve; 200 }; 201 202 dictionary EcdhKeyDeriveParams : Algorithm { 203 required CryptoKey public; 204 }; 205 206 dictionary AesCtrParams : Algorithm { 207 required BufferSource counter; 208 required [EnforceRange] octet length; 209 }; 210 211 dictionary AesKeyAlgorithm : KeyAlgorithm { 212 required unsigned short length; 213 }; 214 215 dictionary AesKeyGenParams : Algorithm { 216 required [EnforceRange] unsigned short length; 217 }; 218 219 dictionary AesDerivedKeyParams : Algorithm { 220 required [EnforceRange] unsigned short length; 221 }; 222 223 dictionary AesCbcParams : Algorithm { 224 required BufferSource iv; 225 }; 226 227 dictionary AesGcmParams : Algorithm { 228 required BufferSource iv; 229 BufferSource additionalData; 230 [EnforceRange] octet tagLength; 231 }; 232 233 dictionary HmacImportParams : Algorithm { 234 required HashAlgorithmIdentifier hash; 235 [EnforceRange] unsigned long length; 236 }; 237 238 dictionary HmacKeyAlgorithm : KeyAlgorithm { 239 required KeyAlgorithm hash; 240 required unsigned long length; 241 }; 242 243 dictionary HmacKeyGenParams : Algorithm { 244 required HashAlgorithmIdentifier hash; 245 [EnforceRange] unsigned long length; 246 }; 247 248 dictionary HkdfParams : Algorithm { 249 required HashAlgorithmIdentifier hash; 250 required BufferSource salt; 251 required BufferSource info; 252 }; 253 254 dictionary Pbkdf2Params : Algorithm { 255 required BufferSource salt; 256 required [EnforceRange] unsigned long iterations; 257 required HashAlgorithmIdentifier hash; 258 };