diff --git a/.travis.yml b/.travis.yml index c0c70cf..116813f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,20 +1,44 @@ -sudo: false language: c -os: - - linux - - osx -dist: xenial +cache: + ccache: true + directories: + - NimV1 +jobs: + include: + - os: linux + arch: amd64 + env: + - NPROC=2 + - NIM_DIR=NimDev + - NIM_BRANCH=devel + dist: xenial + - os: linux + arch: amd64 + env: + - NPROC=2 + - NIM_DIR=NimV1 + - NIM_BRANCH=v1.0.8 + dist: xenial + - os: osx + env: + - NPROC=2 + - NIM_DIR=NimDev + - NIM_BRANCH=devel + before_install: + - HOMEBREW_NO_AUTO_UPDATE=1 HOMEBREW_NO_INSTALL_CLEANUP=1 brew install ccache + - os: osx + env: + - NPROC=2 + - NIM_DIR=NimV1 + - NIM_BRANCH=v1.0.8 + before_install: + - HOMEBREW_NO_AUTO_UPDATE=1 HOMEBREW_NO_INSTALL_CLEANUP=1 brew install ccache + before_script: - - git clone https://github.com/nim-lang/Nim.git - - cd Nim - - git clone --depth 1 https://github.com/nim-lang/csources - - cd csources && sh build.sh - - cd .. - - bin/nim c koch - - ./koch boot -d:release - - ./koch nimble - - export PATH=$(pwd)/bin:$PATH - - cd .. + - ./tests/bootstrap.sh + - export PATH="$(pwd)/$NIM_DIR/bin:$PATH" script: + - echo $PATH + - nim --version - nimble install -y --verbose - nimble test diff --git a/appveyor.yml b/appveyor.yml index e0c0ce2..5ffb91f 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -3,8 +3,8 @@ version: '{build}' cache: - x86_64-8.1.0-release-win32-seh-rt_v6-rev0.7z - i686-8.1.0-release-win32-dwarf-rt_v6-rev0.7z -- sqlite-dll-win64-x64-3310100.zip -- sqlite-dll-win32-x86-3290000.zip +- NimV1x64 +- NimV1x32 matrix: fast_finish: true # set this flag to immediately finish build once one of the jobs fails. @@ -14,35 +14,39 @@ environment: - MINGW_DIR: mingw64 MINGW_URL: https://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win64/Personal%20Builds/mingw-builds/8.1.0/threads-win32/seh/x86_64-8.1.0-release-win32-seh-rt_v6-rev0.7z/download MINGW_ARCHIVE: x86_64-8.1.0-release-win32-seh-rt_v6-rev0.7z - SQLITE_URL: https://www.sqlite.org/2020/sqlite-dll-win64-x64-3310100.zip - SQLITE_ARCHIVE: sqlite-dll-win64-x64-3310100.zip - SQLITE_NAME: sqlite3_64.dll platform: x64 + NIM_DIR: NimDev + NIM_BRANCH: devel + + - MINGW_DIR: mingw64 + MINGW_URL: https://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win64/Personal%20Builds/mingw-builds/8.1.0/threads-win32/seh/x86_64-8.1.0-release-win32-seh-rt_v6-rev0.7z/download + MINGW_ARCHIVE: x86_64-8.1.0-release-win32-seh-rt_v6-rev0.7z + platform: x64 + NIM_DIR: NimV1x64 + NIM_BRANCH: v1.0.8 + - MINGW_DIR: mingw32 MINGW_URL: https://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win32/Personal%20Builds/mingw-builds/8.1.0/threads-win32/dwarf/i686-8.1.0-release-win32-dwarf-rt_v6-rev0.7z/download MINGW_ARCHIVE: i686-8.1.0-release-win32-dwarf-rt_v6-rev0.7z - SQLITE_URL: https://www.sqlite.org/2020/sqlite-dll-win32-x86-3310100.zip - SQLITE_ARCHIVE: sqlite-dll-win32-x86-3310100.zip - SQLITE_NAME: sqlite3_32.dll platform: x86 + NIM_DIR: NimDev + NIM_BRANCH: devel + + - MINGW_DIR: mingw32 + MINGW_URL: https://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win32/Personal%20Builds/mingw-builds/8.1.0/threads-win32/dwarf/i686-8.1.0-release-win32-dwarf-rt_v6-rev0.7z/download + MINGW_ARCHIVE: i686-8.1.0-release-win32-dwarf-rt_v6-rev0.7z + platform: x86 + NIM_DIR: NimV1x32 + NIM_BRANCH: v1.0.8 install: - IF not exist "%MINGW_ARCHIVE%" appveyor DownloadFile "%MINGW_URL%" -FileName "%MINGW_ARCHIVE%" - - IF not exist "%SQLITE_ARCHIVE%" appveyor DownloadFile "%SQLITE_URL%" -FileName "%SQLITE_ARCHIVE%" - 7z x -y "%MINGW_ARCHIVE%" > nul - - SET PATH=%CD%\%MINGW_DIR%\bin;%CD%\Nim\bin;%PATH% - - git clone https://github.com/nim-lang/Nim.git %CD%\Nim - - 7z x -y "%SQLITE_ARCHIVE%" -o"%CD%\Nim\bin" > nul - - RENAME "%CD%\Nim\bin\sqlite3.dll" "%SQLITE_NAME%" - - cd %CD%\Nim - - git clone --depth 1 https://github.com/nim-lang/csources - - cd csources - - IF "%PLATFORM%" == "x64" ( build64.bat ) else ( build.bat ) - - cd .. - - bin\nim c koch - - koch boot -d:release - - koch nimble + - SET PATH=%CD%\%MINGW_DIR%\bin;%CD%\%NIM_DIR%\bin;%PATH% + - tests/bootstrap.bat build_script: + - echo %PATH% + - nim --version - cd C:\projects\nimcrypto - nimble install -y --verbose test_script: diff --git a/nimcrypto.nimble b/nimcrypto.nimble index 65088ef..49966c7 100644 --- a/nimcrypto.nimble +++ b/nimcrypto.nimble @@ -1,6 +1,6 @@ # Package -version = "0.5.3" +version = "0.5.4" author = "Eugene Kabanov" description = "Nim cryptographic library" license = "MIT" diff --git a/nimcrypto/scrypt.nim b/nimcrypto/scrypt.nim index c1146b8..472f0ba 100644 --- a/nimcrypto/scrypt.nim +++ b/nimcrypto/scrypt.nim @@ -188,7 +188,7 @@ func validateParam(N, r, p: int): bool = maxIntd256 = maxInt div 256 let - badParam1 = uint64(r)*uint64(p) >= 1 shl 30 + badParam1 = (uint64(r) * uint64(p)) >= uint64(1 shl 30) badParam2 = r > maxIntd128 div p badParam3 = r > maxIntd256 badParam4 = N > maxIntd128 div r diff --git a/nimcrypto/utils.nim b/nimcrypto/utils.nim index ca04954..b110a82 100644 --- a/nimcrypto/utils.nim +++ b/nimcrypto/utils.nim @@ -87,7 +87,7 @@ proc bytesToHex*(src: openarray[byte], dst: var openarray[char], dst[k + 0] = hexDigit(x shr 4, lowercase) inc(k) - return k + k proc hexToBytes*(src: openarray[char], dst: var openarray[byte], flags: set[HexFlags]): int = diff --git a/tests/bootstrap.bat b/tests/bootstrap.bat new file mode 100644 index 0000000..d47a986 --- /dev/null +++ b/tests/bootstrap.bat @@ -0,0 +1,25 @@ +@echo off +IF NOT EXIST "%CD%\%NIM_DIR%\bin\nim.exe" ( + echo Building Nim [%NIM_BRANCH%] in %NIM_DIR% + git clone https://github.com/nim-lang/Nim.git "%CD%\%NIM_DIR%" + cd "%CD%\%NIM_DIR%" + IF NOT "%NIM_BRANCH%" == "devel" ( + git checkout "tags/%NIM_BRANCH%" -b "%NIM_BRANCH%" + ) ELSE ( + git checkout devel + ) + git clone --depth 1 https://github.com/nim-lang/csources + cd csources + IF "%PLATFORM%" == "x64" ( build64.bat ) else ( build.bat ) + cd .. + bin\nim c -d:release koch + koch boot -d:release + koch nimble + cd .. +) ELSE ( + cd "%CD%\%NIM_DIR%" + set GITBRANCH= + for /f %%I in ('git.exe rev-parse --abbrev-ref HEAD 2^> NUL') do set GITBRANCH=%%I + echo Using Nim [%GITBRANCH%] in %NIM_DIR% + cd .. +) diff --git a/tests/bootstrap.sh b/tests/bootstrap.sh new file mode 100755 index 0000000..f53727b --- /dev/null +++ b/tests/bootstrap.sh @@ -0,0 +1,21 @@ +#!/usr/bin/env bash +if [ ! -e "$NIM_DIR/bin/nim" ]; then + echo "Building Nim [$NIM_BRANCH] in $NIM_DIR" + git clone https://github.com/nim-lang/Nim.git "$NIM_DIR" + cd "$NIM_DIR" + if [ "$NIM_BRANCH" = "devel" ]; then + git checkout devel + else + git checkout "tags/$NIM_BRANCH" -b "$NIM_BRANCH" + fi + git clone --depth 1 https://github.com/nim-lang/csources + cd csources && sh build.sh + cd .. + bin/nim c -d:release koch + ./koch boot -d:release + ./koch nimble -d:release + cd .. +else + GITBRANCH=$(git branch | sed -n -e 's/^\* \(.*\)/\1/p') + echo "Using Nim [$GITBRANCH] in $NIM_DIR" +fi