summaryrefslogtreecommitdiffstats
path: root/toolkit/mozapps/extensions/internal/crypto-utils.sys.mjs
diff options
context:
space:
mode:
Diffstat (limited to 'toolkit/mozapps/extensions/internal/crypto-utils.sys.mjs')
-rw-r--r--toolkit/mozapps/extensions/internal/crypto-utils.sys.mjs10
1 files changed, 9 insertions, 1 deletions
diff --git a/toolkit/mozapps/extensions/internal/crypto-utils.sys.mjs b/toolkit/mozapps/extensions/internal/crypto-utils.sys.mjs
index b1304bcdfc..9ef096df0f 100644
--- a/toolkit/mozapps/extensions/internal/crypto-utils.sys.mjs
+++ b/toolkit/mozapps/extensions/internal/crypto-utils.sys.mjs
@@ -8,6 +8,14 @@ const CryptoHash = Components.Constructor(
"initWithString"
);
+const XPI_WEAK_SIGNATURES = [Ci.nsIAppSignatureInfo.PKCS7_WITH_SHA1];
+
+export function hasStrongSignature(addon) {
+ return !!addon.signedTypes?.filter(
+ algorithm => !XPI_WEAK_SIGNATURES.includes(algorithm)
+ ).length;
+}
+
export function computeHashAsString(hashType, input) {
const data = new Uint8Array(new TextEncoder().encode(input));
const crypto = CryptoHash(hashType);
@@ -42,7 +50,7 @@ export function computeSha1HashAsString(input) {
/**
* Returns the string representation (hex) of a given CryptoHashInstance.
*
- * @param {CryptoHash} aCrypto
+ * @param {nsICryptoHash} aCrypto
* @returns {string}
* The hex representation of a SHA256 hash.
*/