Subversion Repositories Kolibri OS

Rev

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