Subversion Repositories Kolibri OS

Rev

Rev 9216 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. ; libcrash -- cryptographic hash (and other) functions
  2. ;
  3. ; Copyright (C) <2021> Ivan Baravy
  4. ;
  5. ; SPDX-License-Identifier: GPL-2.0-or-later
  6. ;
  7. ; This program is free software: you can redistribute it and/or modify it under
  8. ; the terms of the GNU General Public License as published by the Free Software
  9. ; Foundation, either version 2 of the License, or (at your option) any later
  10. ; version.
  11. ;
  12. ; This program is distributed in the hope that it will be useful, but WITHOUT
  13. ; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  14. ; FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  15. ;
  16. ; You should have received a copy of the GNU General Public License along with
  17. ; this program. If not, see <http://www.gnu.org/licenses/>.
  18.  
  19. ; Based on rfc7539 and implementation of libressl
  20.  
  21. POLY1305_BLOCK_SIZE = 16
  22.  
  23. POLY1305_ALIGN = 16
  24. POLY1305_ALIGN_MASK = POLY1305_ALIGN-1
  25.  
  26. struct ctx_poly1305
  27.         mac             rd 5
  28.                         rd 3
  29.         block           rb POLY1305_BLOCK_SIZE
  30.                         rb POLY1305_ALIGN-(POLY1305_BLOCK_SIZE mod POLY1305_ALIGN)
  31.         index           dd ?
  32.         block_size      dd ?
  33.         hibit           dd ?
  34.                         rd 2    ; align
  35.         ; tmp vars
  36.         r               rd 5
  37.         s               rd 4
  38.         d               rd 5*2  ; 5 dq
  39. ends
  40.  
  41. assert sizeof.ctx_poly1305 <= LIBCRASH_CTX_LEN
  42.  
  43. proc poly1305.init uses ebx, _ctx, _key, _key_len
  44.         mov     ebx, [_ctx]
  45.         mov     [ebx+ctx_poly1305.index], 0
  46.         mov     [ebx+ctx_poly1305.block_size], POLY1305_BLOCK_SIZE
  47.         mov     [ebx+ctx_poly1305.hibit], 1 SHL 24
  48.         ; accumulator
  49.         mov     [ebx+ctx_poly1305.mac+0*4], 0
  50.         mov     [ebx+ctx_poly1305.mac+1*4], 0
  51.         mov     [ebx+ctx_poly1305.mac+2*4], 0
  52.         mov     [ebx+ctx_poly1305.mac+3*4], 0
  53.         mov     [ebx+ctx_poly1305.mac+4*4], 0
  54.         ; r &= 0xffffffc0ffffffc0ffffffc0fffffff
  55.         mov     ecx, [_key]
  56.         mov     eax, [ecx+0]
  57.         and     eax, 0x3ffffff
  58.         mov     [ebx+ctx_poly1305.r+0*4], eax
  59.         mov     eax, [ecx+3]
  60.         shr     eax, 2
  61.         and     eax, 0x3ffff03
  62.         mov     [ebx+ctx_poly1305.r+1*4], eax
  63.         mov     eax, [ecx+6]
  64.         shr     eax, 4
  65.         and     eax, 0x3ffc0ff
  66.         mov     [ebx+ctx_poly1305.r+2*4], eax
  67.         mov     eax, [ecx+9]
  68.         shr     eax, 6
  69.         and     eax, 0x3f03fff
  70.         mov     [ebx+ctx_poly1305.r+3*4], eax
  71.         mov     eax, [ecx+12]
  72.         shr     eax, 8
  73.         and     eax, 0xfffff
  74.         mov     [ebx+ctx_poly1305.r+4*4], eax
  75.         ; s
  76.         mov     eax, [ecx+4*4]
  77.         mov     [ebx+ctx_poly1305.s+0*4], eax
  78.         mov     eax, [ecx+5*4]
  79.         mov     [ebx+ctx_poly1305.s+1*4], eax
  80.         mov     eax, [ecx+6*4]
  81.         mov     [ebx+ctx_poly1305.s+2*4], eax
  82.         mov     eax, [ecx+7*4]
  83.         mov     [ebx+ctx_poly1305.s+3*4], eax
  84.         ret
  85. endp
  86.  
  87.  
  88. proc poly1305._.block _mac
  89. ;        mov     ecx, [ebx+ctx_poly1305.rounds_cnt]
  90.         mov     edi, [_mac]
  91.         ; a += m[i]
  92.         mov     eax, [esi+0]
  93.         and     eax, 0x3ffffff
  94.         add     [ebx+ctx_poly1305.mac+0*4], eax
  95.         mov     eax, [esi+3]
  96.         shr     eax, 2
  97.         and     eax, 0x3ffffff
  98.         add     [ebx+ctx_poly1305.mac+1*4], eax
  99.         mov     eax, [esi+6]
  100.         shr     eax, 4
  101.         and     eax, 0x3ffffff
  102.         add     [ebx+ctx_poly1305.mac+2*4], eax
  103.         mov     eax, [esi+9]
  104.         shr     eax, 6
  105.         and     eax, 0x3ffffff
  106.         add     [ebx+ctx_poly1305.mac+3*4], eax
  107.         mov     eax, [esi+12]
  108.         shr     eax, 8
  109.         or      eax, [ebx+ctx_poly1305.hibit]
  110.         add     [ebx+ctx_poly1305.mac+4*4], eax
  111.  
  112.         ; a *= r
  113.         ; d0
  114.         ; r0*a0
  115.         mov     eax, [ebx+ctx_poly1305.r+0*4]
  116.         mul     [ebx+ctx_poly1305.mac+0*4]
  117.         mov     ecx, eax
  118.         mov     edi, edx
  119.         ; s4*a1
  120.         mov     eax, [ebx+ctx_poly1305.r+4*4]
  121.         lea     eax, [eax*5]
  122.         mul     [ebx+ctx_poly1305.mac+1*4]
  123.         add     ecx, eax
  124.         adc     edi, edx
  125.         ; s3*a2
  126.         mov     eax, [ebx+ctx_poly1305.r+3*4]
  127.         lea     eax, [eax*5]
  128.         mul     [ebx+ctx_poly1305.mac+2*4]
  129.         add     ecx, eax
  130.         adc     edi, edx
  131.         ; s2*a3
  132.         mov     eax, [ebx+ctx_poly1305.r+2*4]
  133.         lea     eax, [eax*5]
  134.         mul     [ebx+ctx_poly1305.mac+3*4]
  135.         add     ecx, eax
  136.         adc     edi, edx
  137.         ; s1*a4
  138.         mov     eax, [ebx+ctx_poly1305.r+1*4]
  139.         lea     eax, [eax*5]
  140.         mul     [ebx+ctx_poly1305.mac+4*4]
  141.         add     ecx, eax
  142.         adc     edi, edx
  143.         mov     [ebx+ctx_poly1305.d+0*8+0], ecx
  144.         mov     [ebx+ctx_poly1305.d+0*8+4], edi
  145.         ; d1
  146.         ; r1*a0
  147.         mov     eax, [ebx+ctx_poly1305.r+1*4]
  148.         mul     [ebx+ctx_poly1305.mac+0*4]
  149.         mov     ecx, eax
  150.         mov     edi, edx
  151.         ; r0*a1
  152.         mov     eax, [ebx+ctx_poly1305.r+0*4]
  153.         mul     [ebx+ctx_poly1305.mac+1*4]
  154.         add     ecx, eax
  155.         adc     edi, edx
  156.         ; s4*a2
  157.         mov     eax, [ebx+ctx_poly1305.r+4*4]
  158.         lea     eax, [eax*5]
  159.         mul     [ebx+ctx_poly1305.mac+2*4]
  160.         add     ecx, eax
  161.         adc     edi, edx
  162.         ; s3*a3
  163.         mov     eax, [ebx+ctx_poly1305.r+3*4]
  164.         lea     eax, [eax*5]
  165.         mul     [ebx+ctx_poly1305.mac+3*4]
  166.         add     ecx, eax
  167.         adc     edi, edx
  168.         ; s2*a4
  169.         mov     eax, [ebx+ctx_poly1305.r+2*4]
  170.         lea     eax, [eax*5]
  171.         mul     [ebx+ctx_poly1305.mac+4*4]
  172.         add     ecx, eax
  173.         adc     edi, edx
  174.         mov     [ebx+ctx_poly1305.d+1*8+0], ecx
  175.         mov     [ebx+ctx_poly1305.d+1*8+4], edi
  176.         ; d2
  177.         ; r2*a0
  178.         mov     eax, [ebx+ctx_poly1305.r+2*4]
  179.         mul     [ebx+ctx_poly1305.mac+0*4]
  180.         mov     ecx, eax
  181.         mov     edi, edx
  182.         ; r1*a1
  183.         mov     eax, [ebx+ctx_poly1305.r+1*4]
  184.         mul     [ebx+ctx_poly1305.mac+1*4]
  185.         add     ecx, eax
  186.         adc     edi, edx
  187.         ; r0*a2
  188.         mov     eax, [ebx+ctx_poly1305.r+0*4]
  189.         mul     [ebx+ctx_poly1305.mac+2*4]
  190.         add     ecx, eax
  191.         adc     edi, edx
  192.         ; s4*a3
  193.         mov     eax, [ebx+ctx_poly1305.r+4*4]
  194.         lea     eax, [eax*5]
  195.         mul     [ebx+ctx_poly1305.mac+3*4]
  196.         add     ecx, eax
  197.         adc     edi, edx
  198.         ; s3*a4
  199.         mov     eax, [ebx+ctx_poly1305.r+3*4]
  200.         lea     eax, [eax*5]
  201.         mul     [ebx+ctx_poly1305.mac+4*4]
  202.         add     ecx, eax
  203.         adc     edi, edx
  204.         mov     [ebx+ctx_poly1305.d+2*8+0], ecx
  205.         mov     [ebx+ctx_poly1305.d+2*8+4], edi
  206.         ; d3
  207.         ; r3*a0
  208.         mov     eax, [ebx+ctx_poly1305.r+3*4]
  209.         mul     [ebx+ctx_poly1305.mac+0*4]
  210.         mov     ecx, eax
  211.         mov     edi, edx
  212.         ; r2*a1
  213.         mov     eax, [ebx+ctx_poly1305.r+2*4]
  214.         mul     [ebx+ctx_poly1305.mac+1*4]
  215.         add     ecx, eax
  216.         adc     edi, edx
  217.         ; r1*a2
  218.         mov     eax, [ebx+ctx_poly1305.r+1*4]
  219.         mul     [ebx+ctx_poly1305.mac+2*4]
  220.         add     ecx, eax
  221.         adc     edi, edx
  222.         ; r0*a3
  223.         mov     eax, [ebx+ctx_poly1305.r+0*4]
  224.         mul     [ebx+ctx_poly1305.mac+3*4]
  225.         add     ecx, eax
  226.         adc     edi, edx
  227.         ; s4*a4
  228.         mov     eax, [ebx+ctx_poly1305.r+4*4]
  229.         lea     eax, [eax*5]
  230.         mul     [ebx+ctx_poly1305.mac+4*4]
  231.         add     ecx, eax
  232.         adc     edi, edx
  233.         mov     [ebx+ctx_poly1305.d+3*8+0], ecx
  234.         mov     [ebx+ctx_poly1305.d+3*8+4], edi
  235.         ; d4
  236.         ; r4*a0
  237.         mov     eax, [ebx+ctx_poly1305.r+4*4]
  238.         mul     [ebx+ctx_poly1305.mac+0*4]
  239.         mov     ecx, eax
  240.         mov     edi, edx
  241.         ; r3*a1
  242.         mov     eax, [ebx+ctx_poly1305.r+3*4]
  243.         mul     [ebx+ctx_poly1305.mac+1*4]
  244.         add     ecx, eax
  245.         adc     edi, edx
  246.         ; r2*a2
  247.         mov     eax, [ebx+ctx_poly1305.r+2*4]
  248.         mul     [ebx+ctx_poly1305.mac+2*4]
  249.         add     ecx, eax
  250.         adc     edi, edx
  251.         ; r1*a3
  252.         mov     eax, [ebx+ctx_poly1305.r+1*4]
  253.         mul     [ebx+ctx_poly1305.mac+3*4]
  254.         add     ecx, eax
  255.         adc     edi, edx
  256.         ; r0*a4
  257.         mov     eax, [ebx+ctx_poly1305.r+0*4]
  258.         mul     [ebx+ctx_poly1305.mac+4*4]
  259.         add     ecx, eax
  260.         adc     edi, edx
  261.         mov     [ebx+ctx_poly1305.d+4*8+0], ecx
  262.         mov     [ebx+ctx_poly1305.d+4*8+4], edi
  263.  
  264.         ; (partial) a %= p
  265.         mov     eax, [ebx+ctx_poly1305.d+0*8+0]
  266.         mov     edx, [ebx+ctx_poly1305.d+0*8+4]
  267.         ; d0
  268.         mov     ecx, edx
  269.         shld    ecx, eax, 6
  270.         and     eax, 0x3ffffff
  271.         mov     [ebx+ctx_poly1305.mac+0*4], eax
  272.         mov     eax, [ebx+ctx_poly1305.d+1*8+0]
  273.         mov     edx, [ebx+ctx_poly1305.d+1*8+4]
  274.         add     eax, ecx
  275.         adc     edx, 0
  276.         ; d1
  277.         mov     ecx, edx
  278.         shld    ecx, eax, 6
  279.         and     eax, 0x3ffffff
  280.         mov     [ebx+ctx_poly1305.mac+1*4], eax
  281.         mov     eax, [ebx+ctx_poly1305.d+2*8+0]
  282.         mov     edx, [ebx+ctx_poly1305.d+2*8+4]
  283.         add     eax, ecx
  284.         adc     edx, 0
  285.         ; d2
  286.         mov     ecx, edx
  287.         shld    ecx, eax, 6
  288.         and     eax, 0x3ffffff
  289.         mov     [ebx+ctx_poly1305.mac+2*4], eax
  290.         mov     eax, [ebx+ctx_poly1305.d+3*8+0]
  291.         mov     edx, [ebx+ctx_poly1305.d+3*8+4]
  292.         add     eax, ecx
  293.         adc     edx, 0
  294.         ; d3
  295.         mov     ecx, edx
  296.         shld    ecx, eax, 6
  297.         and     eax, 0x3ffffff
  298.         mov     [ebx+ctx_poly1305.mac+3*4], eax
  299.         mov     eax, [ebx+ctx_poly1305.d+4*8+0]
  300.         mov     edx, [ebx+ctx_poly1305.d+4*8+4]
  301.         add     eax, ecx
  302.         adc     edx, 0
  303.         ; d4
  304.         mov     ecx, edx
  305.         shld    ecx, eax, 6
  306.         and     eax, 0x3ffffff
  307.         mov     [ebx+ctx_poly1305.mac+4*4], eax
  308.         lea     ecx, [ecx*5]
  309.         add     ecx, [ebx+ctx_poly1305.mac+0*4]
  310.         mov     eax, ecx
  311.         shr     ecx, 26
  312.         and     eax, 0x3ffffff
  313.         mov     [ebx+ctx_poly1305.mac+0*4], eax
  314.         add     [ebx+ctx_poly1305.mac+1*4], ecx
  315.         ret
  316. endp
  317.  
  318.  
  319.  
  320. proc poly1305.update uses ebx esi edi, _ctx, _msg, _size
  321. .next_block:
  322.         mov     ebx, [_ctx]
  323.         mov     esi, [_msg]
  324.         mov     eax, [ebx+ctx_poly1305.index]
  325.         test    eax, eax
  326.         jnz     .copy_to_buf
  327.         test    esi, POLY1305_ALIGN_MASK
  328.         jnz     .copy_to_buf
  329. .no_copy:
  330.         ; data is aligned, process it in place without copying
  331.         mov     ebx, [_ctx]
  332.         mov     eax, [ebx+ctx_poly1305.block_size]
  333.         cmp     [_size], eax
  334.         jb      .copy_quit
  335.         lea     eax, [ebx+ctx_poly1305.mac]
  336.         push    ebx esi
  337.         stdcall poly1305._.block, eax
  338.         pop     esi ebx
  339.         mov     eax, [ebx+ctx_poly1305.block_size]
  340.         sub     [_size], eax
  341.         add     esi, [ebx+ctx_poly1305.block_size]
  342.         jmp     .no_copy
  343.  
  344. .copy_to_buf:
  345.         lea     edi, [ebx+ctx_poly1305.block]
  346.         add     edi, eax
  347.         mov     ecx, [ebx+ctx_poly1305.block_size]
  348.         sub     ecx, eax
  349.         cmp     [_size], ecx
  350.         jb      .copy_quit
  351.         sub     [_size], ecx
  352.         add     [_msg], ecx
  353.         add     [ebx+ctx_poly1305.index], ecx
  354.         mov     eax, [ebx+ctx_poly1305.block_size]
  355.         cmp     [ebx+ctx_poly1305.index], eax
  356.         jb      @f
  357.         sub     [ebx+ctx_poly1305.index], eax
  358. @@:
  359.         rep movsb
  360.         lea     eax, [ebx+ctx_poly1305.mac]
  361.         lea     esi, [ebx+ctx_poly1305.block]
  362.         stdcall poly1305._.block, eax
  363.         jmp     .next_block
  364.  
  365. .copy_quit:
  366.         mov     ebx, [_ctx]
  367.         lea     edi, [ebx+ctx_poly1305.block]
  368.         mov     eax, [ebx+ctx_poly1305.index]
  369.         add     edi, eax
  370.         mov     ecx, [_size]
  371.         add     [ebx+ctx_poly1305.index], ecx
  372.         rep movsb
  373. .quit:
  374.         ret
  375. endp
  376.  
  377. proc poly1305.finish uses ebx esi edi, _ctx
  378.         mov     ebx, [_ctx]
  379.         mov     eax, [ebx+ctx_poly1305.index]
  380.         test    eax, eax
  381.         jz      .skip
  382.         mov     ecx, [ebx+ctx_poly1305.block_size]
  383.         sub     ecx, eax
  384.         lea     edi, [ebx+ctx_poly1305.block]
  385.         add     edi, eax
  386.         mov     byte[edi], 0x01
  387.         inc     edi
  388.         dec     ecx
  389.         jz      @f
  390.         xor     eax, eax
  391.         rep stosb
  392. @@:
  393.  
  394.         mov     ebx, [_ctx]
  395.         mov     [ebx+ctx_poly1305.hibit], 0
  396.         lea     esi, [ebx+ctx_poly1305.block]
  397.         lea     eax, [ebx+ctx_poly1305.mac]
  398.         stdcall poly1305._.block, eax
  399. .skip:
  400.         mov     ebx, [_ctx]
  401.         lea     eax, [ebx+ctx_poly1305.mac]
  402.         stdcall poly1305._.postprocess, ebx, eax
  403.  
  404.         ; fully carry a
  405.         mov     ecx, [ebx+ctx_poly1305.mac+1*4]
  406.         shr     ecx, 26
  407.         and     [ebx+ctx_poly1305.mac+1*4], 0x3ffffff
  408.         add     ecx, [ebx+ctx_poly1305.mac+2*4]
  409.         mov     eax, ecx
  410.         and     eax, 0x3ffffff
  411.         shr     ecx, 26
  412.         mov     [ebx+ctx_poly1305.mac+2*4], eax
  413.         add     ecx, [ebx+ctx_poly1305.mac+3*4]
  414.         mov     eax, ecx
  415.         and     eax, 0x3ffffff
  416.         shr     ecx, 26
  417.         mov     [ebx+ctx_poly1305.mac+3*4], eax
  418.         add     ecx, [ebx+ctx_poly1305.mac+4*4]
  419.         mov     eax, ecx
  420.         and     eax, 0x3ffffff
  421.         shr     ecx, 26
  422.         mov     [ebx+ctx_poly1305.mac+4*4], eax
  423.         lea     ecx, [ecx*5]
  424.         add     ecx, [ebx+ctx_poly1305.mac+0*4]
  425.         mov     eax, ecx
  426.         and     eax, 0x3ffffff
  427.         shr     ecx, 26
  428.         mov     [ebx+ctx_poly1305.mac+0*4], eax
  429.         add     [ebx+ctx_poly1305.mac+1*4], ecx
  430.  
  431.         ; compute a + -p
  432.         mov     ecx, [ebx+ctx_poly1305.mac+0*4]
  433.         add     ecx, 5
  434.         mov     eax, ecx
  435.         and     eax, 0x3ffffff
  436.         shr     ecx, 26
  437.         mov     [ebx+ctx_poly1305.r+0*4], eax
  438.         add     ecx, [ebx+ctx_poly1305.mac+1*4]
  439.         mov     eax, ecx
  440.         and     eax, 0x3ffffff
  441.         shr     ecx, 26
  442.         mov     [ebx+ctx_poly1305.r+1*4], eax
  443.         add     ecx, [ebx+ctx_poly1305.mac+2*4]
  444.         mov     eax, ecx
  445.         and     eax, 0x3ffffff
  446.         shr     ecx, 26
  447.         mov     [ebx+ctx_poly1305.r+2*4], eax
  448.         add     ecx, [ebx+ctx_poly1305.mac+3*4]
  449.         mov     eax, ecx
  450.         and     eax, 0x3ffffff
  451.         shr     ecx, 26
  452.         mov     [ebx+ctx_poly1305.r+3*4], eax
  453.         add     ecx, [ebx+ctx_poly1305.mac+4*4]
  454.         sub     ecx, 1 SHL 26
  455.         mov     [ebx+ctx_poly1305.r+4*4], ecx
  456.  
  457.         ; select a if a < p, or a + -p if a >= p
  458.         shr     ecx, 31
  459.         dec     ecx
  460.         and     [ebx+ctx_poly1305.r+0*4], ecx
  461.         and     [ebx+ctx_poly1305.r+1*4], ecx
  462.         and     [ebx+ctx_poly1305.r+2*4], ecx
  463.         and     [ebx+ctx_poly1305.r+3*4], ecx
  464.         and     [ebx+ctx_poly1305.r+4*4], ecx
  465.         not     ecx
  466.         mov     eax, [ebx+ctx_poly1305.r+0*4]
  467.         and     [ebx+ctx_poly1305.mac+0*4], ecx
  468.         or      [ebx+ctx_poly1305.mac+0*4], eax
  469.         mov     eax, [ebx+ctx_poly1305.r+1*4]
  470.         and     [ebx+ctx_poly1305.mac+1*4], ecx
  471.         or      [ebx+ctx_poly1305.mac+1*4], eax
  472.         mov     eax, [ebx+ctx_poly1305.r+2*4]
  473.         and     [ebx+ctx_poly1305.mac+2*4], ecx
  474.         or      [ebx+ctx_poly1305.mac+2*4], eax
  475.         mov     eax, [ebx+ctx_poly1305.r+3*4]
  476.         and     [ebx+ctx_poly1305.mac+3*4], ecx
  477.         or      [ebx+ctx_poly1305.mac+3*4], eax
  478.         mov     eax, [ebx+ctx_poly1305.r+4*4]
  479.         and     [ebx+ctx_poly1305.mac+4*4], ecx
  480.         or      [ebx+ctx_poly1305.mac+4*4], eax
  481.  
  482.         ; a = a % (2^128)
  483.         ; a0
  484.         mov     eax, [ebx+ctx_poly1305.mac+0*4]
  485.         mov     ecx, [ebx+ctx_poly1305.mac+1*4]
  486.         shl     ecx, 26
  487.         or      eax, ecx
  488.         mov     [ebx+ctx_poly1305.mac+0*4], eax
  489.         ; a1
  490.         mov     eax, [ebx+ctx_poly1305.mac+1*4]
  491.         shr     eax, 6
  492.         mov     ecx, [ebx+ctx_poly1305.mac+2*4]
  493.         shl     ecx, 20
  494.         or      eax, ecx
  495.         mov     [ebx+ctx_poly1305.mac+1*4], eax
  496.         ; a2
  497.         mov     eax, [ebx+ctx_poly1305.mac+2*4]
  498.         shr     eax, 12
  499.         mov     ecx, [ebx+ctx_poly1305.mac+3*4]
  500.         shl     ecx, 14
  501.         or      eax, ecx
  502.         mov     [ebx+ctx_poly1305.mac+2*4], eax
  503.         ; a3
  504.         mov     eax, [ebx+ctx_poly1305.mac+3*4]
  505.         shr     eax, 18
  506.         mov     ecx, [ebx+ctx_poly1305.mac+4*4]
  507.         shl     ecx, 8
  508.         or      eax, ecx
  509.         mov     [ebx+ctx_poly1305.mac+3*4], eax
  510.  
  511.         ; mac = (a + pad) % (2^128)
  512.         xor     edx, edx
  513.         ; a0
  514.         mov     eax, [ebx+ctx_poly1305.mac+0*4]
  515.         add     eax, [ebx+ctx_poly1305.s+0*4]
  516.         mov     [ebx+ctx_poly1305.mac+0*4], eax
  517.         ; a1
  518.         mov     eax, [ebx+ctx_poly1305.mac+1*4]
  519.         adc     eax, [ebx+ctx_poly1305.s+1*4]
  520.         mov     [ebx+ctx_poly1305.mac+1*4], eax
  521.         ; a2
  522.         mov     eax, [ebx+ctx_poly1305.mac+2*4]
  523.         adc     eax, [ebx+ctx_poly1305.s+2*4]
  524.         mov     [ebx+ctx_poly1305.mac+2*4], eax
  525.         ; a3
  526.         mov     eax, [ebx+ctx_poly1305.mac+3*4]
  527.         adc     eax, [ebx+ctx_poly1305.s+3*4]
  528.         mov     [ebx+ctx_poly1305.mac+3*4], eax
  529.         ret
  530. endp
  531.  
  532. proc poly1305._.postprocess _ctx, _mac
  533.         ret
  534. endp
  535.  
  536. proc poly1305.oneshot _ctx, _in, _len, _key, _key_len
  537.         stdcall poly1305.init, [_ctx], [_key], [_key_len]
  538.         stdcall poly1305.update, [_ctx], [_in], [_len]
  539.         stdcall poly1305.finish, [_ctx]
  540.         ret
  541. endp
  542.