rust-crypto 0.2.32

A (mostly) pure-Rust implementation of various common cryptographic algorithms.
Documentation
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// Only works if SSE is supported. We don't know if it is
// on 32-bit x86, but, its always supported in x86-86
#if defined(__x86_64__)

#include <emmintrin.h>

void rust_crypto_ghash_times_x(__m128i* x) {
/*
            asm!("
                movdqa $0, %xmm1
                psrlq $$1, $0
                psllq $$63, %xmm1
                pshufd $$0x0c, %xmm1, %xmm1
                por %xmm1, $0
                " : "+x" (self.d) : : "xmm1" );
*/
    asm(
        " \
            movdqu (%0), %%xmm1 \
            mov %%xmm1, %%xmm2 \
            psrlq $1, %%xmm2 \
            psllq $63, %%xmm1 \
            pshufd $0x0c, %%xmm1, %%xmm1 \
            por %%xmm1, %%xmm2 \
            movdqu %%xmm2, (%0) \
        "
    : "+m" (x) // outputs
    : // inputs
    : "xmm1", "xmm2" // clobbers
    );
}

void rust_crypto_ghash_cond_xor() {
/*
            asm!("
                movdqa $1, %xmm1
                pand $3, %xmm1
                pcmpeqd $3, %xmm1
                pshufd $$0x00, %xmm1, %xmm1
                pand $2, %xmm1
                pxor %xmm1, $0
                " : "+x" (y.d) : "x" (self.d), "x" (x.d), "x" (lsb) : "xmm1"
            );
*/
    asm(
        " \
        "
    : // outputs
    : // inputs
    : "xmm1", "memory" // clobbers
    );
}

#endif