All of lore.kernel.org
 help / color / mirror / Atom feed
From: Richard Henderson <richard.henderson@linaro.org>
To: liweiwei <liweiwei@iscas.ac.cn>,
	palmer@dabbelt.com, alistair.francis@wdc.com,
	bin.meng@windriver.com, qemu-riscv@nongnu.org,
	qemu-devel@nongnu.org
Cc: wangjunqiang@iscas.ac.cn, lazyparser@gmail.com,
	luruibo2000@163.com, lustrew@foxmail.com
Subject: Re: [RFC 4/6] target/riscv: rvk: add implementation of instructions for Zk*
Date: Tue, 2 Nov 2021 14:56:02 -0400	[thread overview]
Message-ID: <345c3fc7-72f9-a5b8-1545-fe7835ed8905@linaro.org> (raw)
In-Reply-To: <20211102031128.17296-5-liweiwei@iscas.ac.cn>

On 11/1/21 11:11 PM, liweiwei wrote:
> +uint8_t AES_ENC_SBOX[] = {
> +  0x63, 0x7C, 0x77, 0x7B, 0xF2, 0x6B, 0x6F, 0xC5,
> +  0x30, 0x01, 0x67, 0x2B, 0xFE, 0xD7, 0xAB, 0x76,
> +  0xCA, 0x82, 0xC9, 0x7D, 0xFA, 0x59, 0x47, 0xF0,
> +  0xAD, 0xD4, 0xA2, 0xAF, 0x9C, 0xA4, 0x72, 0xC0,

Use "crypto/aes.h".


> +/* SM4 forward SBox. SM4 has no inverse sbox. */
> +static const uint8_t sm4_sbox[256] = {
> +    0xD6, 0x90, 0xE9, 0xFE, 0xCC, 0xE1, 0x3D, 0xB7, 0x16, 0xB6, 0x14, 0xC2,
> +    0x28, 0xFB, 0x2C, 0x05, 0x2B, 0x67, 0x9A, 0x76, 0x2A, 0xBE, 0x04, 0xC3,
> +    0xAA, 0x44, 0x13, 0x26, 0x49, 0x86, 0x06, 0x99, 0x9C, 0x42, 0x50, 0xF4,

Hmm.  We have an existing copy of this in target/arm/crypto_helper.c.  I think we should 
move that code out to a shared location like aes.

> +#define sext_xlen(x) (((int64_t)(x) << (XLEN - 32)) >> (XLEN  - 32))

This is (target_ulong)(int32_t)(x).


r~


WARNING: multiple messages have this Message-ID (diff)
From: Richard Henderson <richard.henderson@linaro.org>
To: liweiwei <liweiwei@iscas.ac.cn>,
	palmer@dabbelt.com, alistair.francis@wdc.com,
	bin.meng@windriver.com, qemu-riscv@nongnu.org,
	qemu-devel@nongnu.org
Cc: wangjunqiang@iscas.ac.cn, lazyparser@gmail.com,
	lustrew@foxmail.com, luruibo2000@163.com
Subject: Re: [RFC 4/6] target/riscv: rvk: add implementation of instructions for Zk*
Date: Tue, 2 Nov 2021 14:56:02 -0400	[thread overview]
Message-ID: <345c3fc7-72f9-a5b8-1545-fe7835ed8905@linaro.org> (raw)
In-Reply-To: <20211102031128.17296-5-liweiwei@iscas.ac.cn>

On 11/1/21 11:11 PM, liweiwei wrote:
> +uint8_t AES_ENC_SBOX[] = {
> +  0x63, 0x7C, 0x77, 0x7B, 0xF2, 0x6B, 0x6F, 0xC5,
> +  0x30, 0x01, 0x67, 0x2B, 0xFE, 0xD7, 0xAB, 0x76,
> +  0xCA, 0x82, 0xC9, 0x7D, 0xFA, 0x59, 0x47, 0xF0,
> +  0xAD, 0xD4, 0xA2, 0xAF, 0x9C, 0xA4, 0x72, 0xC0,

Use "crypto/aes.h".


> +/* SM4 forward SBox. SM4 has no inverse sbox. */
> +static const uint8_t sm4_sbox[256] = {
> +    0xD6, 0x90, 0xE9, 0xFE, 0xCC, 0xE1, 0x3D, 0xB7, 0x16, 0xB6, 0x14, 0xC2,
> +    0x28, 0xFB, 0x2C, 0x05, 0x2B, 0x67, 0x9A, 0x76, 0x2A, 0xBE, 0x04, 0xC3,
> +    0xAA, 0x44, 0x13, 0x26, 0x49, 0x86, 0x06, 0x99, 0x9C, 0x42, 0x50, 0xF4,

Hmm.  We have an existing copy of this in target/arm/crypto_helper.c.  I think we should 
move that code out to a shared location like aes.

> +#define sext_xlen(x) (((int64_t)(x) << (XLEN - 32)) >> (XLEN  - 32))

This is (target_ulong)(int32_t)(x).


r~


  reply	other threads:[~2021-11-02 18:56 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-02  3:11 [RFC 0/6] support subsets of scalar crypto extension liweiwei
2021-11-02  3:11 ` liweiwei
2021-11-02  3:11 ` [RFC 1/6] target/riscv: rvk: add flag support for Zbk[bcx] liweiwei
2021-11-02  3:11   ` liweiwei
2021-11-02 14:18   ` Richard Henderson
2021-11-02 14:18     ` Richard Henderson
2021-11-02 15:00     ` liweiwei
2021-11-02 15:00       ` liweiwei
2021-11-02  3:11 ` [RFC 2/6] target/riscv: rvk: add implementation of instructions for Zbk* - reuse partial instructions of Zbb/Zbc extensions - add brev8 packh, unzip, zip, etc liweiwei
2021-11-02  3:11   ` liweiwei
2021-11-02 15:44   ` Richard Henderson
2021-11-02 15:44     ` Richard Henderson
2021-11-03  0:56     ` liweiwei
2021-11-03  0:56       ` liweiwei
2021-11-02  3:11 ` [RFC 3/6] target/riscv: rvk: add flag support for Zk/Zkn/Zknd/Zknd/Zkne/Zknh/Zks/Zksed/Zksh/Zkr liweiwei
2021-11-02  3:11   ` liweiwei
2021-11-02 17:56   ` Richard Henderson
2021-11-02 17:56     ` Richard Henderson
2021-11-03  1:06     ` liweiwei
2021-11-03  1:06       ` liweiwei
2021-11-03  1:21       ` Richard Henderson
2021-11-03  1:21         ` Richard Henderson
2021-11-03  7:22         ` liweiwei
2021-11-03  7:22           ` liweiwei
2021-11-02  3:11 ` [RFC 4/6] target/riscv: rvk: add implementation of instructions for Zk* liweiwei
2021-11-02  3:11   ` liweiwei
2021-11-02 18:56   ` Richard Henderson [this message]
2021-11-02 18:56     ` Richard Henderson
2021-11-03  1:08     ` liweiwei
2021-11-03  1:08       ` liweiwei
2021-11-02  3:11 ` [RFC 5/6] target/riscv: rvk: add CSR support for Zkr: - add SEED CSR - add USEED, SSEED fields for MSECCFG CSR liweiwei
2021-11-02  3:11   ` liweiwei
2021-11-02  3:11 ` [RFC 6/6] disas/riscv.c: rvk: add disas support for Zbk* and Zk* instructions liweiwei
2021-11-02  3:11   ` liweiwei

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=345c3fc7-72f9-a5b8-1545-fe7835ed8905@linaro.org \
    --to=richard.henderson@linaro.org \
    --cc=alistair.francis@wdc.com \
    --cc=bin.meng@windriver.com \
    --cc=lazyparser@gmail.com \
    --cc=liweiwei@iscas.ac.cn \
    --cc=luruibo2000@163.com \
    --cc=lustrew@foxmail.com \
    --cc=palmer@dabbelt.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-riscv@nongnu.org \
    --cc=wangjunqiang@iscas.ac.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.