( format, wrappedKey, unwrappingKey, unwrapAlgorithm, unwrappedKeyAlgorithm, extractable, keyUsages)
| 1091 | } |
| 1092 | |
| 1093 | function unwrapKeyImpl( |
| 1094 | format, |
| 1095 | wrappedKey, |
| 1096 | unwrappingKey, |
| 1097 | unwrapAlgorithm, |
| 1098 | unwrappedKeyAlgorithm, |
| 1099 | extractable, |
| 1100 | keyUsages) { |
| 1101 | const prefix = prepareSubtleMethod(this, 'unwrapKey', arguments.length, 7); |
| 1102 | let i = 0; |
| 1103 | format = convertSubtleArgument(prefix, 'KeyFormat', format, i++); |
| 1104 | wrappedKey = convertSubtleArgument(prefix, 'BufferSource', wrappedKey, i++); |
| 1105 | unwrappingKey = convertSubtleArgument( |
| 1106 | prefix, 'CryptoKey', unwrappingKey, i++); |
| 1107 | const algorithm = convertSubtleArgument( |
| 1108 | prefix, 'AlgorithmIdentifier', unwrapAlgorithm, i++); |
| 1109 | unwrappedKeyAlgorithm = convertSubtleArgument( |
| 1110 | prefix, 'AlgorithmIdentifier', unwrappedKeyAlgorithm, i++); |
| 1111 | extractable = convertSubtleArgument(prefix, 'boolean', extractable, i++); |
| 1112 | const usages = convertSubtleArgument( |
| 1113 | prefix, 'sequence<KeyUsage>', keyUsages, i++); |
| 1114 | |
| 1115 | let normalizedAlgorithm; |
| 1116 | try { |
| 1117 | normalizedAlgorithm = normalizeAlgorithm(algorithm, 'unwrapKey'); |
| 1118 | } catch { |
| 1119 | normalizedAlgorithm = normalizeAlgorithm(algorithm, 'decrypt'); |
| 1120 | } |
| 1121 | |
| 1122 | const normalizedKeyAlgorithm = |
| 1123 | normalizeAlgorithm(unwrappedKeyAlgorithm, 'importKey'); |
| 1124 | |
| 1125 | if (normalizedAlgorithm.name !== getCryptoKeyAlgorithm(unwrappingKey).name) |
| 1126 | throw lazyDOMException('Key algorithm mismatch', 'InvalidAccessError'); |
| 1127 | |
| 1128 | if (!hasCryptoKeyUsage(unwrappingKey, 'unwrapKey')) |
| 1129 | throw lazyDOMException( |
| 1130 | 'Unable to use this key to unwrapKey', 'InvalidAccessError'); |
| 1131 | |
| 1132 | const bytes = cipherOrWrap( |
| 1133 | kWebCryptoCipherDecrypt, |
| 1134 | normalizedAlgorithm, |
| 1135 | unwrappingKey, |
| 1136 | wrappedKey); |
| 1137 | |
| 1138 | return jobPromiseThen(bytes, (bytes) => { |
| 1139 | let keyData = bytes; |
| 1140 | if (format === 'jwk') { |
| 1141 | keyData = parseJwk(bytes); |
| 1142 | } |
| 1143 | |
| 1144 | return FunctionPrototypeCall( |
| 1145 | importKeySync, |
| 1146 | this, |
| 1147 | format, |
| 1148 | keyData, |
| 1149 | normalizedKeyAlgorithm, |
| 1150 | extractable, |
nothing calls this directly
no test coverage detected
searching dependent graphs…