MCPcopy
hub / github.com/IvanMathy/Boop / binb

Function binb

Boop/Boop/scripts/lib/hashes.js:792–834  ·  view source on GitHub ↗

* Calculate the SHA-1 of an array of big-endian words, and a bit length

(x, len)

Source from the content-addressed store, hash-verified

790 */
791
792 function binb(x, len) {
793 var i, j, t, olda, oldb, oldc, oldd, olde,
794 w = Array(80),
795 a = 1732584193,
796 b = -271733879,
797 c = -1732584194,
798 d = 271733878,
799 e = -1009589776;
800
801 /* append padding */
802 x[len >> 5] |= 0x80 << (24 - len % 32);
803 x[((len + 64 >> 9) << 4) + 15] = len;
804
805 for (i = 0; i < x.length; i += 16) {
806 olda = a;
807 oldb = b;
808 oldc = c;
809 oldd = d;
810 olde = e;
811
812 for (j = 0; j < 80; j += 1) {
813 if (j < 16) {
814 w[j] = x[i + j];
815 } else {
816 w[j] = bit_rol(w[j - 3] ^ w[j - 8] ^ w[j - 14] ^ w[j - 16], 1);
817 }
818 t = safe_add(safe_add(bit_rol(a, 5), sha1_ft(j, b, c, d)),
819 safe_add(safe_add(e, w[j]), sha1_kt(j)));
820 e = d;
821 d = c;
822 c = bit_rol(b, 30);
823 b = a;
824 a = t;
825 }
826
827 a = safe_add(a, olda);
828 b = safe_add(b, oldb);
829 c = safe_add(c, oldc);
830 d = safe_add(d, oldd);
831 e = safe_add(e, olde);
832 }
833 return Array(a, b, c, d, e);
834 }
835
836 /**
837 * Perform the appropriate triplet combination function for the current

Callers 2

rstrFunction · 0.85
rstr_hmacFunction · 0.85

Calls 15

bit_rolFunction · 0.85
safe_addFunction · 0.85
sha1_ftFunction · 0.85
sha1_ktFunction · 0.85
sha256_Gamma1256Function · 0.85
sha256_Gamma0256Function · 0.85
sha256_Sigma1256Function · 0.85
sha256_ChFunction · 0.85
sha256_Sigma0256Function · 0.85
sha256_MajFunction · 0.85
int64copyFunction · 0.85
int64rrotFunction · 0.85

Tested by

no test coverage detected