Algoritmo a chiave pubblica più veloce a scopo di test

5

Come parte di una suite di test automatizzata ho bisogno di eseguire molti processi gpg --encrypt e gpg --decrypt .

Per rendere più veloce ogni chiamata di gpg --encrypt e gpg --decrypt , mi piacerebbe utilizzare un algoritmo a chiave pubblica molto veloce.

Comprendo che i cifrari più veloci sono anche quelli che forniscono la sicurezza più debole, specialmente per le dimensioni di chiavi piccole. La sicurezza, tuttavia, non è un problema importante in questo caso: la chiave passphrase-less è anche rilasciata pubblicamente come parte della suite di test.

Per riferimento, questo è ciò che supporta la mia versione di GnuPG:

Pubkey: RSA, ELG, DSA
Cipher: 3DES, CAST5, BLOWFISH, AES, AES192, AES256, TWOFISH, CAMELLIA128, 
        CAMELLIA192, CAMELLIA256
Hash: MD5, SHA1, RIPEMD160, SHA256, SHA384, SHA512, SHA224
Compression: Uncompressed, ZIP, ZLIB, BZIP2

Per ricapitolare, qual è la combinazione più veloce di algoritmo e lunghezza della chiave disponibile in GnuPG?

    
posta gioele 08.06.2014 - 12:03
fonte

1 risposta

2

Questo cambierà da macchina a macchina e da binario GPG a binario GPG; la macchina offre istruzioni AES-NI, il tuo binario GPG li usa, usa le operazioni a 64 bit, le istruzioni XOP o AVX sono disponibili e usate dal tuo binario, ecc.

C'è una sola risposta: confrontala sulla tua particolare configurazione!

Daniel Kahn Gillmor ha pubblicato solo uno script di riferimento sugli utenti di gnupg lista nel 2010, compresa una somma SHA1 e una firma, naturalmente.

Nota che l'output proviene dal comando Unix time, formattato come + in secondi.

Se vuoi qualcosa di diverso, modifica lo script!

#!/bin/sh

# Author: Daniel Kahn Gillmor <[email protected]>
# Date: Tue, 28 Sep 2010 14:25:19 -0400

# This script produces some roughly-formatted OpenPGP performance data
# against different algorithms and keysizes


set -e

REPEAT=100
ASYM_ALGOS="RSA DSA"
KEY_SIZES="1024 2048 3072 4096"
DIGESTS="SHA1 SHA224 SHA256 SHA384 SHA512"
CIPHERS="3DES AES AES192 AES256"

if gpg --debug-quick-random --version >/dev/null 2>/dev/null ; then
    QUICKRANDOM=--debug-quick-random
elif gpg --quick-random --version >/dev/null 2>/dev/null ; then
    QUICKRANDOM=--quick-random
else
    printf "don't know how to set quick random number generation"
    exit 2
fi

encalgo() {
    if [ "$1" = "DSA" ]; then
    printf "ELG-E"
    else
    printf "%s" "$1"
    fi
}

describe_system() {
    # FIXME: this is fairly Linux-specific.  it'd be better to use
    # something more generic to get info about the CPU and RAM
    # available:
    cat /proc/cpuinfo 2>&1 || :
    free 2>&1 || :
    uname -a
    gpg --version
}

# quick key creation:
setup() {
    rm -f testmsg
    for rep in $(seq 1 25) ; do
    echo "this is a test message for benchmarking OpenPGP signature validation times." >> testmsg
    done
    for algo in $ASYM_ALGOS; do
    for size in $KEY_SIZES; do
        if [ "$algo" = "DSA" ] && [ "$size" -gt 3072 ]; then
        # gpg can't do DSA > 3072 bits
        continue
        fi
        mkdir -m 0700 -p ${algo}-${size}
        if printf 'Key-Type: %s
Key-Length: %s
Key-Usage: sign
Subkey-Type: %s
Subkey-Length: %s
Subkey-Usage: encrypt
Name-Real: OpenPGP Benchmark Key %s %s bits
Name-Comment: DO NOT USE!
' "$algo" "$size" $(encalgo "$algo") "$size" "$algo" "$size" | GNUPGHOME=${algo}-${size} gpg $QUICKRANDOM --batch --gen-key ; then
        for digest in $DIGESTS; do
            output=${algo}-${size}/testmsg.${algo}-${size}-${digest}.asc
            if ! GNUPGHOME=${algo}-${size} gpg --digest-algo "$digest" --clearsign < testmsg > ${output} ; then
            rm -f ${output}
            fi
        done

        for cipher in $CIPHERS; do
            output=${algo}-${size}/testmsg.${algo}-${size}-${cipher}.asc
            if ! GNUPGHOME=${algo}-${size} gpg --armor --cipher-algo "$cipher" --encrypt -r 'Benchmark' < testmsg > ${output} ; then
            rm -f ${output}
            fi
        done
        else
        rm -rf ${algo}-${size}
        fi
    done
    done
}


signing() {
    for algo in $ASYM_ALGOS ; do
    printf '%s Signing (x%d)\n' $algo $REPEAT
    for length in 'digest:' $KEY_SIZES; do
        if [ -d "${algo}-${length}" ] || [ "$length" = 'digest:' ]; then
        printf '%s\t' "$length"
        for digest in $DIGESTS; do
            if [ "$length" = 'digest:' ]; then
            printf '%s\t' "$digest"
            else
            for x in ${algo}-${length}/*; do
                cat < "$x" > /dev/null
            done
            targfile=${algo}-${length}/testmsg.${algo}-${length}-${digest}.asc
            if [ -e $targfile ]; then
                stats=$(bash -c "time -p for seq in $(seq 1 $REPEAT | tr '\n' ' '); do
GNUPGHOME=${algo}-${length} gpg --digest-algo $digest --sign >/dev/null 2>/dev/null < ./testmsg
done" 2>&1)
                printf '%s+%s\t' $(printf "%s" "$stats" | grep ^user | cut -f2 -d' ') $(printf "%s" "$stats" | grep ^sys | cut -f2 -d' ')
            else
                printf 'X\t'
            fi
            fi
        done
        printf '\n'
        fi
    done
    done
}

verifying() { 
    for algo in $ASYM_ALGOS ; do
    printf '%s Verifying (x%d)\n' $algo $REPEAT
    for length in 'digest:' $KEY_SIZES; do
        if [ -d "${algo}-${length}" ] || [ "$length" = 'digest:' ]; then
        printf '%s\t' "$length"
        for digest in $DIGESTS; do
            if [ "$length" = 'digest:' ]; then
            printf '%s\t' "$digest"
            else
            for x in ${algo}-${length}/*; do
                cat < "$x" > /dev/null
            done
            targfile=${algo}-${length}/testmsg.${algo}-${length}-${digest}.asc
            if [ -e $targfile ]; then
                stats=$(bash -c "time -p for seq in $(seq 1 $REPEAT | tr '\n' ' '); do
GNUPGHOME=${algo}-${length} gpg --verify >/dev/null 2>/dev/null < $targfile
done" 2>&1)
                printf '%s+%s\t' $(printf "%s" "$stats" | grep ^user | cut -f2 -d' ') $(printf "%s" "$stats" | grep ^sys | cut -f2 -d' ')
            else
                printf 'X\t'
            fi
            fi
        done
        printf '\n'
        fi
    done
    done
}


encrypting() {
    for algo in $ASYM_ALGOS ; do
    printf '%s Encrypting (x%s)\n' $(encalgo "$algo") $REPEAT
    for length in 'cipher:' $KEY_SIZES; do
        if [ -d "${algo}-${length}" ] || [ "$length" = 'cipher:' ]; then
        printf '%s\t' "$length"
        for cipher in $CIPHERS; do
            if [ "$length" = 'cipher:' ]; then
            printf '%s\t' "$cipher"
            else
            for x in ${algo}-${length}/*; do
                cat < "$x" > /dev/null
            done
            targfile=${algo}-${length}/testmsg.${algo}-${length}-${cipher}.asc
            if [ -e $targfile ]; then
                stats=$(bash -c "time -p for seq in $(seq 1 $REPEAT | tr '\n' ' '); do
GNUPGHOME=${algo}-${length} gpg --cipher-algo $cipher --encrypt -r Benchmark >/dev/null 2>/dev/null < ./testmsg
done" 2>&1)
                printf '%s+%s\t' $(printf "%s" "$stats" | grep ^user | cut -f2 -d' ') $(printf "%s" "$stats" | grep ^sys | cut -f2 -d' ')
            else
                printf 'X\t'
            fi
            fi
        done
        printf '\n'
        fi
    done
    done
}


decrypting() {
    for algo in $ASYM_ALGOS ; do
    printf '%s Decrypting (x%s)\n' $(encalgo "$algo") $REPEAT
    for length in 'cipher:' $KEY_SIZES; do
        if [ -d "${algo}-${length}" ] || [ "$length" = 'cipher:' ]; then
        printf '%s\t' "$length"
        for cipher in $CIPHERS; do
            if [ "$length" = 'cipher:' ]; then
            printf '%s\t' "$cipher"
            else
            for x in ${algo}-${length}/*; do
                cat < "$x" > /dev/null
            done
            targfile=${algo}-${length}/testmsg.${algo}-${length}-${cipher}.asc
            if [ -e $targfile ]; then
                stats=$(bash -c "time -p for seq in $(seq 1 $REPEAT | tr '\n' ' '); do
GNUPGHOME=${algo}-${length} gpg --decrypt >/dev/null 2>/dev/null < $targfile
done" 2>&1)
                printf '%s+%s\t' $(printf "%s" "$stats" | grep ^user | cut -f2 -d' ') $(printf "%s" "$stats" | grep ^sys | cut -f2 -d' ')
            else
                printf 'X\t'
            fi
            fi
        done
        printf '\n'
        fi
    done
    done
}


run() {
    WORKDIR=$(mktemp -d "${TMPDIR:-/tmp}/openpgp-benchmark.XXXXXX")
    OUTPUT=$(mktemp "$(pwd)/openpgp-benchmark.$(date +%F_%T | tr ':' '-').XXXXXX")
    printf 'Working in %s...\n' "$WORKDIR"
    cd "$WORKDIR"
    ( describe_system
        setup
        signing
        verifying
        encrypting 
        decrypting ) | tee "$OUTPUT"
    printf 'log written to %s...\nPlease mail back to Daniel Kahn Gillmor <[email protected]>.\n' "$OUTPUT"
}

action="$1"
if [ "x$action" = "x" ]; then
    action=run
fi

case "$action" in
    setup|describe_system|signing|verifying|encrypting|run)
        "$action"
        ;;
    *)
        echo "Usage: $0 [setup|describe_system|signing|verifying|encrypting|run]  " >&2
        exit 2
        ;;
esac
    
risposta data 31.01.2016 - 05:24
fonte

Leggi altre domande sui tag