You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

common.js 907B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. 'use strict';
  2. var utils = require('../utils');
  3. var rotr32 = utils.rotr32;
  4. function ft_1(s, x, y, z) {
  5. if (s === 0)
  6. return ch32(x, y, z);
  7. if (s === 1 || s === 3)
  8. return p32(x, y, z);
  9. if (s === 2)
  10. return maj32(x, y, z);
  11. }
  12. exports.ft_1 = ft_1;
  13. function ch32(x, y, z) {
  14. return (x & y) ^ ((~x) & z);
  15. }
  16. exports.ch32 = ch32;
  17. function maj32(x, y, z) {
  18. return (x & y) ^ (x & z) ^ (y & z);
  19. }
  20. exports.maj32 = maj32;
  21. function p32(x, y, z) {
  22. return x ^ y ^ z;
  23. }
  24. exports.p32 = p32;
  25. function s0_256(x) {
  26. return rotr32(x, 2) ^ rotr32(x, 13) ^ rotr32(x, 22);
  27. }
  28. exports.s0_256 = s0_256;
  29. function s1_256(x) {
  30. return rotr32(x, 6) ^ rotr32(x, 11) ^ rotr32(x, 25);
  31. }
  32. exports.s1_256 = s1_256;
  33. function g0_256(x) {
  34. return rotr32(x, 7) ^ rotr32(x, 18) ^ (x >>> 3);
  35. }
  36. exports.g0_256 = g0_256;
  37. function g1_256(x) {
  38. return rotr32(x, 17) ^ rotr32(x, 19) ^ (x >>> 10);
  39. }
  40. exports.g1_256 = g1_256;