Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Linux/arch/powerpc/crypto/   (Open Source Betriebssystem Version 6.17.9©)  Datei vom 24.10.2025 mit Größe 10 kB image not shown  

Quelle  curve25519-ppc64le_asm.S

  Sprache: Sparc
 

/* SPDX-License-Identifier: GPL-2.0-or-later */
#
# This code is taken from CRYPTOGAMs[1] and is included here using the option
# in the license to distribute the code under the GPL. Therefore this program
# is free software; you can redistribute it and/or modify it under the terms of
# the GNU General Public License version 2 as published by the Free Software
# Foundation.
#
# [1https://github.com/dot-asm/cryptogams/

# Copyright (c) 2006-2017, CRYPTOGAMS by <appro@openssl.org>
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
#       * Redistributions of source code must retain copyright notices,
#         this list of conditions and the following disclaimer.
#
#       * Redistributions in binary form must reproduce the above
#         copyright notice, this list of conditions and the following
#         disclaimer in the documentation and/or other materials
#         provided with the distribution.
#
#       * Neither the name of the CRYPTOGAMS nor the names of its
#         copyright holder and contributors may be used to endorse or
#         promote products derived from this software without specific
#         prior written permission.
#
# ALTERNATIVELY, provided that this notice is retained in full, this
# product may be distributed under the terms of the GNU General Public
# License (GPL), in which case the provisions of the GPL apply INSTEAD OF
# those given above.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

# ====================================================================
# Written by Andy Polyakov <appro@openssl.org> for the OpenSSL
# project. The module is, however, dual licensed under OpenSSL and
# CRYPTOGAMS licenses depending on where you obtain it. For further
# details see https://www.openssl.org/~appro/cryptogams/.
# ====================================================================

#
# ====================================================================
# Written and Modified by Danny Tsen <dtsen@us.ibm.com>
# - Added x25519_fe51_sqr_times, x25519_fe51_frombytes, x25519_fe51_tobytes
#   and x25519_cswap
#
# Copyright 2024- IBM Corp.
#
# X25519 lower-level primitives for PPC64.
#

#include <linux/linkage.h>

.text

.align 5
SYM_FUNC_START(x25519_fe51_mul)

 stdu 1,-144(1)
 std 21,56(1)
 std 22,64(1)
 std 23,72(1)
 std 24,80(1)
 std 25,88(1)
 std 26,96(1)
 std 27,104(1)
 std 28,112(1)
 std 29,120(1)
 std 30,128(1)
 std 31,136(1)

 ld 6,0(5)
 ld 7,0(4)
 ld 8,8(4)
 ld 9,16(4)
 ld 10,24(4)
 ld 11,32(4)

 mulld 22,7,6
 mulhdu 23,7,6

 mulld 24,8,6
 mulhdu 25,8,6

 mulld 30,11,6
 mulhdu 31,11,6
 ld 4,8(5)
 mulli 11,11,19

 mulld 26,9,6
 mulhdu 27,9,6

 mulld 28,10,6
 mulhdu 29,10,6
 mulld 12,11,4
 mulhdu 21,11,4
 addc 22,22,12
 adde 23,23,21

 mulld 12,7,4
 mulhdu 21,7,4
 addc 24,24,12
 adde 25,25,21

 mulld 12,10,4
 mulhdu 21,10,4
 ld 6,16(5)
 mulli 10,10,19
 addc 30,30,12
 adde 31,31,21

 mulld 12,8,4
 mulhdu 21,8,4
 addc 26,26,12
 adde 27,27,21

 mulld 12,9,4
 mulhdu 21,9,4
 addc 28,28,12
 adde 29,29,21
 mulld 12,10,6
 mulhdu 21,10,6
 addc 22,22,12
 adde 23,23,21

 mulld 12,11,6
 mulhdu 21,11,6
 addc 24,24,12
 adde 25,25,21

 mulld 12,9,6
 mulhdu 21,9,6
 ld 4,24(5)
 mulli 9,9,19
 addc 30,30,12
 adde 31,31,21

 mulld 12,7,6
 mulhdu 21,7,6
 addc 26,26,12
 adde 27,27,21

 mulld 12,8,6
 mulhdu 21,8,6
 addc 28,28,12
 adde 29,29,21
 mulld 12,9,4
 mulhdu 21,9,4
 addc 22,22,12
 adde 23,23,21

 mulld 12,10,4
 mulhdu 21,10,4
 addc 24,24,12
 adde 25,25,21

 mulld 12,8,4
 mulhdu 21,8,4
 ld 6,32(5)
 mulli 8,8,19
 addc 30,30,12
 adde 31,31,21

 mulld 12,11,4
 mulhdu 21,11,4
 addc 26,26,12
 adde 27,27,21

 mulld 12,7,4
 mulhdu 21,7,4
 addc 28,28,12
 adde 29,29,21
 mulld 12,8,6
 mulhdu 21,8,6
 addc 22,22,12
 adde 23,23,21

 mulld 12,9,6
 mulhdu 21,9,6
 addc 24,24,12
 adde 25,25,21

 mulld 12,10,6
 mulhdu 21,10,6
 addc 26,26,12
 adde 27,27,21

 mulld 12,11,6
 mulhdu 21,11,6
 addc 28,28,12
 adde 29,29,21

 mulld 12,7,6
 mulhdu 21,7,6
 addc 30,30,12
 adde 31,31,21

.Lfe51_reduce:
 li 0,-1
 srdi 0,0,13

 srdi 12,26,51
 and 9,26,0
 insrdi 12,27,51,0
 srdi 21,22,51
 and 7,22,0
 insrdi 21,23,51,0
 addc 28,28,12
 addze 29,29
 addc 24,24,21
 addze 25,25

 srdi 12,28,51
 and 10,28,0
 insrdi 12,29,51,0
 srdi 21,24,51
 and 8,24,0
 insrdi 21,25,51,0
 addc 30,30,12
 addze 31,31
 add 9,9,21

 srdi 12,30,51
 and 11,30,0
 insrdi 12,31,51,0
 mulli 12,12,19

 add 7,7,12

 srdi 21,9,51
 and 9,9,0
 add 10,10,21

 srdi 12,7,51
 and 7,7,0
 add 8,8,12

 std 9,16(3)
 std 10,24(3)
 std 11,32(3)
 std 7,0(3)
 std 8,8(3)

 ld 21,56(1)
 ld 22,64(1)
 ld 23,72(1)
 ld 24,80(1)
 ld 25,88(1)
 ld 26,96(1)
 ld 27,104(1)
 ld 28,112(1)
 ld 29,120(1)
 ld 30,128(1)
 ld 31,136(1)
 addi 1,1,144
 blr
SYM_FUNC_END(x25519_fe51_mul)

.align 5
SYM_FUNC_START(x25519_fe51_sqr)

 stdu 1,-144(1)
 std 21,56(1)
 std 22,64(1)
 std 23,72(1)
 std 24,80(1)
 std 25,88(1)
 std 26,96(1)
 std 27,104(1)
 std 28,112(1)
 std 29,120(1)
 std 30,128(1)
 std 31,136(1)

 ld 7,0(4)
 ld 8,8(4)
 ld 9,16(4)
 ld 10,24(4)
 ld 11,32(4)

 add 6,7,7
 mulli 21,11,19

 mulld 22,7,7
 mulhdu 23,7,7
 mulld 24,8,6
 mulhdu 25,8,6
 mulld 26,9,6
 mulhdu 27,9,6
 mulld 28,10,6
 mulhdu 29,10,6
 mulld 30,11,6
 mulhdu 31,11,6
 add 6,8,8
 mulld 12,11,21
 mulhdu 11,11,21
 addc 28,28,12
 adde 29,29,11

 mulli 5,10,19

 mulld 12,8,8
 mulhdu 11,8,8
 addc 26,26,12
 adde 27,27,11
 mulld 12,9,6
 mulhdu 11,9,6
 addc 28,28,12
 adde 29,29,11
 mulld 12,10,6
 mulhdu 11,10,6
 addc 30,30,12
 adde 31,31,11
 mulld 12,21,6
 mulhdu 11,21,6
 add 6,10,10
 addc 22,22,12
 adde 23,23,11
 mulld 12,10,5
 mulhdu 10,10,5
 addc 24,24,12
 adde 25,25,10
 mulld 12,6,21
 mulhdu 10,6,21
 add 6,9,9
 addc 26,26,12
 adde 27,27,10

 mulld 12,9,9
 mulhdu 10,9,9
 addc 30,30,12
 adde 31,31,10
 mulld 12,5,6
 mulhdu 10,5,6
 addc 22,22,12
 adde 23,23,10
 mulld 12,21,6
 mulhdu 10,21,6
 addc 24,24,12
 adde 25,25,10

 b .Lfe51_reduce
SYM_FUNC_END(x25519_fe51_sqr)

.align 5
SYM_FUNC_START(x25519_fe51_mul121666)

 stdu 1,-144(1)
 std 21,56(1)
 std 22,64(1)
 std 23,72(1)
 std 24,80(1)
 std 25,88(1)
 std 26,96(1)
 std 27,104(1)
 std 28,112(1)
 std 29,120(1)
 std 30,128(1)
 std 31,136(1)

 lis 6,1
 ori 6,6,56130
 ld 7,0(4)
 ld 8,8(4)
 ld 9,16(4)
 ld 10,24(4)
 ld 11,32(4)

 mulld 22,7,6
 mulhdu 23,7,6
 mulld 24,8,6
 mulhdu 25,8,6
 mulld 26,9,6
 mulhdu 27,9,6
 mulld 28,10,6
 mulhdu 29,10,6
 mulld 30,11,6
 mulhdu 31,11,6

 b .Lfe51_reduce
SYM_FUNC_END(x25519_fe51_mul121666)

.align 5
SYM_FUNC_START(x25519_fe51_sqr_times)

 stdu 1,-144(1)
 std 21,56(1)
 std 22,64(1)
 std 23,72(1)
 std 24,80(1)
 std 25,88(1)
 std 26,96(1)
 std 27,104(1)
 std 28,112(1)
 std 29,120(1)
 std 30,128(1)
 std 31,136(1)

 ld 7,0(4)
 ld 8,8(4)
 ld 9,16(4)
 ld 10,24(4)
 ld 11,32(4)

 mtctr 5

.Lsqr_times_loop:
 add 6,7,7
 mulli 21,11,19

 mulld 22,7,7
 mulhdu 23,7,7
 mulld 24,8,6
 mulhdu 25,8,6
 mulld 26,9,6
 mulhdu 27,9,6
 mulld 28,10,6
 mulhdu 29,10,6
 mulld 30,11,6
 mulhdu 31,11,6
 add 6,8,8
 mulld 12,11,21
 mulhdu 11,11,21
 addc 28,28,12
 adde 29,29,11

 mulli 5,10,19

 mulld 12,8,8
 mulhdu 11,8,8
 addc 26,26,12
 adde 27,27,11
 mulld 12,9,6
 mulhdu 11,9,6
 addc 28,28,12
 adde 29,29,11
 mulld 12,10,6
 mulhdu 11,10,6
 addc 30,30,12
 adde 31,31,11
 mulld 12,21,6
 mulhdu 11,21,6
 add 6,10,10
 addc 22,22,12
 adde 23,23,11
 mulld 12,10,5
 mulhdu 10,10,5
 addc 24,24,12
 adde 25,25,10
 mulld 12,6,21
 mulhdu 10,6,21
 add 6,9,9
 addc 26,26,12
 adde 27,27,10

 mulld 12,9,9
 mulhdu 10,9,9
 addc 30,30,12
 adde 31,31,10
 mulld 12,5,6
 mulhdu 10,5,6
 addc 22,22,12
 adde 23,23,10
 mulld 12,21,6
 mulhdu 10,21,6
 addc 24,24,12
 adde 25,25,10

 # fe51_reduce
 li 0,-1
 srdi 0,0,13

 srdi 12,26,51
 and 9,26,0
 insrdi 12,27,51,0
 srdi 21,22,51
 and 7,22,0
 insrdi 21,23,51,0
 addc 28,28,12
 addze 29,29
 addc 24,24,21
 addze 25,25

 srdi 12,28,51
 and 10,28,0
 insrdi 12,29,51,0
 srdi 21,24,51
 and 8,24,0
 insrdi 21,25,51,0
 addc 30,30,12
 addze 31,31
 add 9,9,21

 srdi 12,30,51
 and 11,30,0
 insrdi 12,31,51,0
 mulli 12,12,19

 add 7,7,12

 srdi 21,9,51
 and 9,9,0
 add 10,10,21

 srdi 12,7,51
 and 7,7,0
 add 8,8,12

 bdnz .Lsqr_times_loop

 std 9,16(3)
 std 10,24(3)
 std 11,32(3)
 std 7,0(3)
 std 8,8(3)

 ld 21,56(1)
 ld 22,64(1)
 ld 23,72(1)
 ld 24,80(1)
 ld 25,88(1)
 ld 26,96(1)
 ld 27,104(1)
 ld 28,112(1)
 ld 29,120(1)
 ld 30,128(1)
 ld 31,136(1)
 addi 1,1,144
 blr
SYM_FUNC_END(x25519_fe51_sqr_times)

.align 5
SYM_FUNC_START(x25519_fe51_frombytes)

 li 12, -1
 srdi 121213 # 0x7ffffffffffff

 ld 50(4)
 ld 68(4)
 ld 716(4)
 ld 824(4)

 srdi 10551
 and 5512 # h0

 sldi 11613
 or 111011 # h1t
 srdi 10638
 and 61112 # h1

 sldi 11726
 or 101011 # h2t

 srdi 11725
 and 71012 # h2
 sldi 10839
 or 111110 # h3t

 srdi 9812
 and 81112 # h3
 and 9912 # h4

 std 50(3)
 std 68(3)
 std 716(3)
 std 824(3)
 std 932(3)

 blr
SYM_FUNC_END(x25519_fe51_frombytes)

.align 5
SYM_FUNC_START(x25519_fe51_tobytes)

 ld 50(4)
 ld 68(4)
 ld 716(4)
 ld 824(4)
 ld 932(4)

 li 12, -1
 srdi 121213 # 0x7ffffffffffff

 # Full reducuction
 addi 10519
 srdi 101051
 add 10106
 srdi 101051
 add 10107
 srdi 101051
 add 10108
 srdi 101051
 add 10109
 srdi 101051

 mulli 101019
 add 5510
 srdi 11551
 add 6611
 srdi 11651
 add 7711
 srdi 11751
 add 8811
 srdi 11851
 add 9911

 and 5512
 and 6612
 and 7712
 and 8812
 and 9912

 sldi 10651
 or 5510 # s0

 srdi 11613
 sldi 10738
 or 61110 # s1

 srdi 11726
 sldi 10825
 or 71110 # s2

 srdi 11839
 sldi 10912
 or 81110 # s4

 std 50(3)
 std 68(3)
 std 716(3)
 std 824(3)

 blr
SYM_FUNC_END(x25519_fe51_tobytes)

.align 5
SYM_FUNC_START(x25519_cswap)

 li 75
 neg 65
 mtctr 7

.Lswap_loop:
 ld 80(3)
 ld 90(4)
 xor 1089
 and 10106
 xor 11810
 xor 12910
 std 110(3)
 addi 338
 std 120(4)
 addi 448
 bdnz .Lswap_loop

 blr
SYM_FUNC_END(x25519_cswap)

Messung V0.5 in Prozent
C=93 H=93 G=92

¤ Dauer der Verarbeitung: 0.15 Sekunden  (vorverarbeitet am  2026-06-06) ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.