MCPcopy Index your code
hub / github.com/NativeScript/NativeScript / decrypt

Method decrypt

packages/core/wgc/crypto/SubtleCrypto.ts:305–348  ·  view source on GitHub ↗
(algorithm: RsaOaepParams, key: CryptoKey, data: TypedArray | ArrayBuffer)

Source from the content-addressed store, hash-verified

303 }
304
305 decrypt(algorithm: RsaOaepParams, key: CryptoKey, data: TypedArray | ArrayBuffer) {
306 return new Promise((resolve, reject) => {
307 let error: Error;
308 switch (algorithm?.name) {
309 case 'RSA-OAEP':
310 {
311 try {
312 if (__IOS__) {
313 const hash = parseHash(key.algorithm.hash.name);
314 const d = NSData.dataWithData(data as never);
315 NSCCrypto.decryptRsaKeyHashDataCompletion(key.type === 'private', key[parent_], hash, d, (ret, error) => {
316 if (ret) {
317 resolve(interop.bufferFromData(ret));
318 } else {
319 reject(new Error('Failed to decrypt data'));
320 }
321 });
322 }
323
324 if (__ANDROID__) {
325 const hash = parseHash(key.algorithm.hash.name);
326 const ret = (<any>org).nativescript.winter_tc.Crypto.decryptRsaOAEP(key[parent_], hash, data);
327 if (ret) {
328 resolve((<any>ArrayBuffer).from(ret));
329 } else {
330 reject(new Error('Failed to decrypt data'));
331 }
332 }
333 } catch (error) {
334 reject(error);
335 }
336 }
337 break;
338 default:
339 error = new Error('Operation is not supported');
340 break;
341 }
342
343 if (error) {
344 reject(error);
345 return;
346 }
347 });
348 }
349
350 sign(algorithm: { name: 'HMAC' } | 'HMAC', key: CryptoKey, data: TypedArray | ArrayBuffer) {
351 return new Promise((resolve, reject) => {

Callers 1

gen_rsa_oaepFunction · 0.80

Calls 3

parseHashFunction · 0.85
decryptRsaOAEPMethod · 0.80
resolveFunction · 0.50

Tested by

no test coverage detected