Giter Club home page Giter Club logo

asm-hashes's People

Contributors

dependabot[bot] avatar dgbo avatar dignifiedquire avatar elliottslaughter avatar froydnj avatar haraldh avatar jeremyd2019 avatar linkmauve avatar newpavlov avatar nobodyxu avatar rubdos avatar striezel avatar tarcieri avatar tlercher avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

asm-hashes's Issues

bench failed on Windows

env: Windows 10 x86_64, Rust nightly-gnu [rustc 1.55.0-nightly (539d7bd39 2021-06-14)]

❯ cargo +nightly-gnu bench -vvv
       Fresh cc v1.0.61
       Fresh md5-asm v0.5.0 (C:\workspace\repos\github.com\RustCrypto\asm-hashes\md5)
    Finished bench [optimized] target(s) in 0.04s
     Running `C:\workspace\repos\github.com\RustCrypto\asm-hashes\target\release\deps\md5_asm-4aede987d9726e5b.exe --bench`

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

     Running `C:\workspace\repos\github.com\RustCrypto\asm-hashes\target\release\deps\lib-dab98c6ec0ebcfb5.exe --bench`

running 1 test
error: bench failed

How can I fix this?

MSVC support

Output of cargo run --release in a project using md5-asm via md-5:

   Compiling md5-asm v0.4.3
The following warnings were emitted during compilation:

warning: cl : Command line warning D9024 : unrecognized source file type 'src/x64.S', object file assumed
warning: cl : Command line warning D9027 : source file 'src/x64.S' ignored

error: failed to run custom build command for `md5-asm v0.4.3`

Caused by:
  process didn't exit successfully: `K:\Code\project\target\release\build\md5-asm-2f85d6e6f786c14b\build-script-build` (exit code: 1)
  --- stdout
  TARGET = Some("x86_64-pc-windows-msvc")
  OPT_LEVEL = Some("3")
  HOST = Some("x86_64-pc-windows-msvc")
  CC_x86_64-pc-windows-msvc = None
  CC_x86_64_pc_windows_msvc = None
  HOST_CC = None
  CC = None
  CFLAGS_x86_64-pc-windows-msvc = None
  CFLAGS_x86_64_pc_windows_msvc = None
  HOST_CFLAGS = None
  CFLAGS = None
  CRATE_CC_NO_DEFAULTS = None
  CARGO_CFG_TARGET_FEATURE = Some("fxsr,sse,sse2")
  DEBUG = Some("false")
  running: "K:\\Code\\Microsoft Visual Studio\\2019\\Community\\VC\\Tools\\MSVC\\14.27.29110\\bin\\HostX64\\x64\\cl.exe" "-nologo" "-MD" "-O2" "-Brepro" "-W4" "-c" "-FoK:\\Code\\project\\target\\release\\build\\md5-asm-86902935336c4579\\out\\src/x64.o" "-c" "src/x64.S"
  cargo:warning=cl : Command line warning D9024 : unrecognized source file type 'src/x64.S', object file assumed
  cargo:warning=cl : Command line warning D9027 : source file 'src/x64.S' ignored
  cl : Command line warning D9021 : no action performed
  exit code: 0
  AR_x86_64-pc-windows-msvc = None
  AR_x86_64_pc_windows_msvc = None
  HOST_AR = None
  AR = None
  running: "K:\\Code\\Microsoft Visual Studio\\2019\\Community\\VC\\Tools\\MSVC\\14.27.29110\\bin\\HostX64\\x64\\lib.exe" "-out:K:\\Code\\project\\target\\release\\build\\md5-asm-86902935336c4579\\out\\libmd5.a" "-nologo" "K:\\Code\\project\\target\\release\\build\\md5-asm-86902935336c4579\\out\\src/x64.o"
  LINK : fatal error LNK1181: cannot open input file 'K:\Code\project\target\release\build\md5-asm-86902935336c4579\out\src\x64.o'
  exit code: 1181

  --- stderr


  error occurred: Command "K:\\Code\\Microsoft Visual Studio\\2019\\Community\\VC\\Tools\\MSVC\\14.27.29110\\bin\\HostX64\\x64\\lib.exe" "-out:K:\\Code\\project\\target\\release\\build\\md5-asm-86902935336c4579\\out\\libmd5.a" "-nologo" "K:\\Code\\project\\target\\release\\build\\md5-asm-86902935336c4579\\out\\src/x64.o" with args "lib.exe" did not execute successfully (status code exit code: 1181).

Based on the .S files I don't think this project intends to support Windows. In that case it'd be nice if the project just gave a compile error saying Windows isn't supported rather than a confusing MSVC failure log.

s390x support for asm-hashes

Hello,

While building https://github.com/filecoin-project/lotus on s390x platform on a Big Endian architecture, saw an error message filecoin-project/lotus#1779 and I followed the suggestions to build libfilcrypto.so from the source.

While doing so, the build failed because it was depending on asm-hashes and it did not have support for s390x platform.

To get going, we have generated .S based on the https://www.nayuki.io/res/fast-sha2-hashes-in-x86-assembly/sha256.c for example. This got us going with building libfilcrypto for s390x. However, not sure if this is the right thing to do since we could have used .c file directly anyway.

Would you have any plans on providing an implementation for s390x ?

Migrating to inline assembly (Rust 1.59)

With the forthcoming release of Rust 1.59 at the end of February, which stabilizes inline assembly, I think it's time to start planning on eventually retiring this repo and migrating to inline assembly instead.

This should simplify a number of things like linking, testing, and overall crate/repo structure.

md5 `thread 'main' has overflowed its stack`

  • Compiling md5-asm with clang appears thread 'main' has overflowed its stack
    md-5 = { version = "0.10.5", features = ["oid", "asm"] }
[env]
CC = "clang"

clang version 16.0.0
Target: x86_64-pc-windows-msvc
Thread model: posix

Example

use ::md5::{Digest, Md5};

fn main() {
    println!("start md5");
    let mut m5: Md5 = Md5::new();
    m5.update(
        b"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
    );
    println!("{:x}", m5.finalize())
}

sha-1: asm fails to build on i686 and aarch64

Apologies, I'm unsure if this is specifically an issue with hashes or maybe has something to do with an interaction with cross, but when I attempt to cross-compile to aarch64-unknown-linux-gnu it seems to chose invalid assembly instructions.

Part of the output of:


   Compiling sha1-asm v0.4.4
The following warnings were emitted during compilation:

warning: src/x64.S: Assembler messages:
warning: src/x64.S:111: Error: unknown mnemonic `movq' -- `movq %rbx,%xmm0'
warning: src/x64.S:112: Error: unknown mnemonic `movq' -- `movq %rbp,%xmm1'
warning: src/x64.S:113: Error: unknown mnemonic `subq' -- `subq $64,%rsp'
warning: src/x64.S:116: Error: unknown mnemonic `movq' -- `movq %rdi,%r8'
warning: src/x64.S:117: Error: unknown mnemonic `movl' -- `movl 0(%rdi),%eax'
warning: src/x64.S:118: Error: unknown mnemonic `movl' -- `movl 4(%rdi),%ebx'
warning: src/x64.S:119: Error: unknown mnemonic `movl' -- `movl 8(%rdi),%ecx'
warning: src/x64.S:120: Error: unknown mnemonic `movl' -- `movl 12(%rdi),%edx'
warning: src/x64.S:121: Error: unknown mnemonic `movl' -- `movl 16(%rdi),%ebp'
warning: src/x64.S:122: Error: unknown mnemonic `movq' -- `movq %rsi,%rdi'

See full output here along with Cargo.toml and src/main.rs here: https://gist.github.com/jszwedko/9d0cfb8db04fdeffb83cae1f1e2acec4

sha1-asm fails to link on i686-pc-windows-gnu

Ran into a build failure of starship over in msys2/MINGW-packages#17831. It seems to me that sha1/src/x86.S needs to prefix the symbol with _ on Windows as it does for Apple. This would at least fix the build error.

  • Add leading _ for i686 Windows
  • Confirm calling convention matches (no crash at runtime)
  • Add COFF symbol type cruft (so it is properly marked as a function rather than data) (this should be done to x86_64 and aarch64 too)
    .def    _sha1_compress;  .scl    2;  .type   32; .endef
    

I plan to open a pull request with these changes, once I figure out how to test them (insights into this would be appreciated). I also want to test aarch64-pc-windows-gnullvm target, as I bet nobody has tried this yet.

Add a RISCV implementation

Currently, the software implementation of sha256 suffers from a performance bug in code generation on RISC-V targets. Additionally, I think that a target-specific implementation has a lot of potential for improvement compared to the current generic implementation. (The generic implementation has a lot of manual loop unrolling and is primed for compiler autovectorization. RISC-V does not profit from these, as vector operations are still WIP. I suspect that a simpler implementation would have less register pressure and thus better performance, in addition to smaller code)

Migrate to assembly from OpenSSL

Initially crates in this repository were a simple proof-of-work experiment and assembly from Project Nayuki was taken without much consideration to performance. But some people use asm feature and expect performance on par with OpenSSL which is obviously not true today.

So I think we should migrate to OpenSSL assembly and maybe rename this repository to openssl-asm or something. This will require some code refactoring as OpenSSL hash assembly processes several blocks at a time and for the best performance we will have to accommodate for it. My initial experiments with MD5 haven't found any difficult problems.

The main question I currently have is: should we pack Perl scripts into crates or generated assembly? First option will result in a lighter crates (especially considering various possible "flavors" which Perl scripts support), but will require Perl to be installed on the system. For Linux it's not a big deal, but I think for Windows it can be a problem.

Cross compilation because of usage of target_arch in build.rs

Hello,

I tried to cross compile the sha2 crate for aarch64-linux-android as a dependency of sha2. This failes because the build.rs uses target_arch which is the host machine the build.rs is built on in order to be run during the build process. I don't know how to check to the actual target in a build.rs

Here's a suggestion but open: rust-lang/cargo#4932

For now I sadly kind of forked and patched but I'm happy to implement a suggestion and test...

cheers,

@flxo

Improve benchmarks

Right now we use single-element slices in benchmarks, it could be worth to use something like [Block; 1024] instead.

Also we do not test that benchmark can be built in CI, which has caused a regression in #30, fixed later in #31.

sha1: Apple M1 build failures

As discovered on #27, the aarch64 assembly for the sha1 and sha2 (edit: SHA-256 support added in #35) crates does not compile on macOS/M1:

Compiling sha2-asm v0.5.4
The following warnings were emitted during compilation:

warning: src/sha256_aarch64.S:64:2: error: ADR/ADRP relocations must be GOT relative
warning:  adrp x2, .K
warning:  ^
warning: src/sha256_aarch64.S:64:2: error: unknown AArch64 fixup kind!
warning:  adrp x2, .K
warning:  ^
warning: src/sha256_aarch64.S:65:2: error: unknown AArch64 fixup kind!
warning:  add x2, x2, :lo12:.K
warning:  ^

error: failed to run custom build command for `sha2-asm v0.5.4`

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.