Hash input.
801 {
802 static const uint32_t *const k = _k();
803
804
805
806
807
808
809
810
811 while(const uint8_t *p = _calc_chunk(data, bytes))
812 {
813
814
815
816 alignas(32) uint32_t ah[8];
817
818
819 memcpy(ah, _h.
as_ints,
sizeof(ah));
820
821
822
823
824
825 alignas(32) uint32_t w[64];
826 for(unsigned i = 0; i < 16; i++)
827 {
828 w[i] = ((uint32_t) p[0] << 24) | ((uint32_t) p[1] << 16) | ((uint32_t) p[2] << 8) | ((uint32_t) p[3]);
829 p += 4;
830 }
831
832 for(unsigned i = 16; i < 64; i++)
833 {
834 const uint32_t s0 = _right_rot(w[i - 15], 7) ^ _right_rot(w[i - 15], 18) ^ (w[i - 15] >> 3);
835 const uint32_t s1 = _right_rot(w[i - 2], 17) ^ _right_rot(w[i - 2], 19) ^ (w[i - 2] >> 10);
836 w[i] = w[i - 16] + s0 + w[i - 7] + s1;
837 }
838
839
840 for(unsigned i = 0; i < 64; i++)
841 {
842 const uint32_t s1 = _right_rot(ah[4], 6) ^ _right_rot(ah[4], 11) ^ _right_rot(ah[4], 25);
843 const uint32_t ch = (ah[4] & ah[5]) ^ (~ah[4] & ah[6]);
844 const uint32_t temp1 = ah[7] + s1 + ch + k[i] + w[i];
845 const uint32_t s0 = _right_rot(ah[0], 2) ^ _right_rot(ah[0], 13) ^ _right_rot(ah[0], 22);
846 const uint32_t maj = (ah[0] & ah[1]) ^ (ah[0] & ah[2]) ^ (ah[1] & ah[2]);
847 const uint32_t temp2 = s0 + maj;
848
849 ah[7] = ah[6];
850 ah[6] = ah[5];
851 ah[5] = ah[4];
852 ah[4] = ah[3] + temp1;
853 ah[3] = ah[2];
854 ah[2] = ah[1];
855 ah[1] = ah[0];
856 ah[0] = temp1 + temp2;
857 }
858
859
860 for(unsigned i = 0; i < 8; i++)
862 }
863 }
uint32_t as_ints[8]
Definition hash.hpp:725