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

Method verify

packages/core/wgc/crypto/SubtleCrypto.ts:414–474  ·  view source on GitHub ↗
(algorithm: { name: 'HMAC' } | 'HMAC', key: CryptoKey, signature: ArrayBuffer, data: ArrayBuffer)

Source from the content-addressed store, hash-verified

412 }
413
414 verify(algorithm: { name: 'HMAC' } | 'HMAC', key: CryptoKey, signature: ArrayBuffer, data: ArrayBuffer) {
415 return new Promise((resolve, reject) => {
416 let error: Error;
417 const algorithmName = typeof algorithm === 'object' ? algorithm?.name : algorithm;
418 switch (algorithmName) {
419 case 'HMAC':
420 {
421 try {
422 if (__IOS__) {
423 const hash = parseHash(key.algorithm.hash.name);
424 const s = NSData.dataWithData(signature as never);
425 const d = NSData.dataWithData(data as never);
426
427 const ret = NSCCrypto.verifyHmacHashSignatureData(key[native_], hash, s, d);
428 resolve(ret);
429 }
430
431 if (__ANDROID__) {
432 let algo;
433 switch (key.algorithm.hash.name) {
434 case 'SHA-1':
435 algo = 'HmacSHA1';
436 break;
437 case 'SHA-256':
438 algo = 'HmacSHA256';
439 break;
440 case 'SHA-384':
441 algo = 'HmacSHA384';
442 break;
443 case 'SHA-512':
444 algo = 'HmacSHA512';
445 break;
446 default:
447 error = new Error('Operation is not supported');
448 break;
449 }
450
451 if (error) {
452 reject(error);
453 return;
454 }
455
456 const ret = (<any>org).nativescript.winter_tc.Crypto.verifyHMAC(algo, key[native_], signature, data);
457 resolve(ret);
458 }
459 } catch (error) {
460 reject(error);
461 }
462 }
463 break;
464 default:
465 error = new Error('Operation is not supported');
466 break;
467 }
468
469 if (error) {
470 reject(error);
471 return;

Callers 1

gen_hmacFunction · 0.80

Calls 3

parseHashFunction · 0.85
verifyHMACMethod · 0.80
resolveFunction · 0.50

Tested by

no test coverage detected