sha256 of libgcrypt is 10 times slower then busybox sha25sum util on qualcomm IPQ4018 board

袁建鹏 yuanjp89 at
Sat Jun 5 13:54:07 CEST 2021


I link libgcrypt to calculate the sha256 checksum of router firmware. the code snippets of calcuate sha256 checksum looks like this:

uint8_t digest[32];
void *handle;
char buf[40960];


    do {
        ret = read(fd, buf, sizeof(buf));
        if (ret < 0)
            return -ERR_READ;
        if (ret > 0)
            sha256_update(handle, buf, ret);
    } while (ret > 0);

    sha256_final(handle, digest);

Caculate the sha256 of a 6MB file need 3 secoands:
 # TIME=%e time ./fwtool check ipq4018.bin

but If i use the sha256sum command provided by busybox, only need 0.4s:
# TIME=%e time sha256sum ipq4018.bin
1b4807030b82f07815b7c34d3d32aa06b29081c15b8eb2a2284a5069b962c137  ipq4018.bin

the libgcrypt build configure in IPQ4018 (ARM cortext A7 soc):
conf := --disable-doc --enable-neon-support \
    --with-libgpg-error-prefix=$(APP_BUILD)/libgpg-error/ \
    --enable-digests="md5 rmd160 sha1 sha256 sha512 blake2" \
    --enable-ciphers="arcfour des aes cast5 chacha20" \
    --enable-pubkey-ciphers="rsa dsa ecc" \

Is this a problem ? the busybox code seems no hardware support. why libgcrypt is slower so much  than busybox.

Thanks very much.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the Gnupg-users mailing list