Light Mode

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

cryptogus/KD-Biscuit-Ciphers

Repository files navigation

  • KBC
    • Status
    • Windows build
    • Linux build
    • Cross compilation

https://asecuritysite.com/ -> I think it's the best site on cryptography.

To do

Implementing PKCS#11 API

Kookmin Biscuit Cipher (KBC) for students

KBC is an C program for testing block cipher.

Currently, it has been tested only on Linux in 2023.11

This content follows GNU GENERAL PUBLIC LICENSE Version 3.

Cryptographic Calculation Tool http://cryptomanager.com/

Environmental System Information

CPU: quad core 11th Gen Intel Core i7-1165G7
Kernel: 5.15.133.1-microsoft-standard-WSL2 x86_64
RAM: 7.6 GiB

Status

Padding

  • PKCS#7 (Currently in stationary use)
  • ISO9797 M2 (Currently available for testing only)

Block Ciphers

  • AES: AES-128, AES-192, AES-256
  • PIPO: PIPO64/128, PIPO64/256
  • LEA: LEA-128, LEA-192, LEA-256
  • SEED: SEED128
  • ARIA: ARIA-128, ARIA-192, ARIA-256
  • TDEA: Triple Data Encryption Algorithm(Triple DES): complete only test

Stream Cipher

  • ChaCha20(Not yet reflected in the GUI)

Public-key cryptography(asymmetric cryptography)

  • RSA: RSA2048

Modes of Operation

  • ECB
  • CBC
  • CTR (I developed the code so that it is not available for blocks that are not 16 bytes in size.)

https://crypto.stackexchange.com/questions/88783/ctr-block-generation https://crypto.stackexchange.com/questions/18267/how-do-we-compute-iv1-in-ctr-mode https://stackoverflow.com/questions/12529612/interoperability-of-aes-ctr-mode https://github.com/openssl/openssl/blob/master/crypto/modes/ctr128.c - CTR mode is big-endian

TEST test/TDEA-KAT

  • The Multi-block Message Test (MMT) for TDES

  • The Monte Carlo Test (MCT) for TDES

  • The Multi-block Message Test (MMT) for AES (not yet)

  • The Monte Carlo Test (MCT) for AES (not yet)

reference: https://csrc.nist.gov/Projects/cryptographic-algorithm-validation-program/Block-Ciphers

Windows

  1. git https://git-scm.com/download/win

  2. msvc compiler & nmake https://visualstudio.microsoft.com/ko/downloads/

  3. cmake downloads https://cmake.org/download/

    I chose Windows x64 Installer. Make sure to choose one that fits your environment.

  4. build first: I ran "C:\Program Files (x86)\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvars64.bat"

    second: I used x64 Native Tools Command Prompt for VS 2022 in the "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Visual Studio 2022\Visual Studio Tools\VC" location.

    PS> cmake -B build -S . && cd build
    PS> nmake

Linux

On Ubuntu:

  1. Install dependencies:

    $ sudo apt update
    $ sudo apt upgrade
    $ sudo apt install git cmake gcc build-essential libssl-dev valgrind ninja

    # Qt (for gui)
    $ sudo apt install qt5-qmake qtbase5-dev
  2. Build OpenSSL can be disabled when the user forwards it from the command line, such as -DUSE_OPENSSL=OFF. OpenSSL is used only on rsa2048.

    $ cmake -B build -S .&& cd build
    # $ cmake -B build -S . -DUSE_OPENSSL=OFF && cd build
    $ make -j$(nproc)

    After running make install and executing ldconfig, the openKBC executable will be accessible from any location in the terminal. This is because the installation process places the executable in /usr/local/bin, and ldconfig updates the system's library cache to include the path to the shared libraries, allowing the executable to find them regardless of the current working directory.

    $ sudo make install
    $ sudo ldconfig
    gyeceung gujo

    build/
    +-- openKBC
    +-- src/
    | +-- libKBC.so
    +-- test/
    +-- CBC_test
    +-- ECB_test
    +-- aes_test
    +-- AES-KEY-EXPANSION-TEST
    +-- aria_test
    +-- pipo_test
    +-- lea_test
    +-- seed_test
    +-- chacha20_test
    +-- rsa2048_test
    +-- chacha_block_test
    +-- chacha_quarter_round_test
    +-- chacha_encrypt_test
    +-- iso9797m2-test
    +-- pks7-test
    +-- TDEA-KAT
    +-- ecb_mmt_test
    +-- ecb_mct_test
    +-- cbc_mmt_parity_test
    +-- cbc_mct_patity_test
    KBC_gui/
    +--libKBC.so
  3. Test

    $ cd test

    You can test each function in this test directory.

    example:

    $ ./aes-test
  4. After completing course 2, run openKBC from the build directory.

  5. The KBC dynamic library is created at the build/src location. (Using with api.h)

  6. How to run applications after building in the main directory

    $ build/openKBC
  7. gui build (unfinished) - hyeonjae Decrypt gineungeseo pyeongmun culryeogi an doeneun deungyi gita beogeu jonjae, widget.cppeul sujeonghaeyaham, Qte daehan jisig pilyo

    $ cd KBC_gui
    $ mkdir build
    $ cd build
    $ qmake ..
    $ make -j$(nproc)
    $ ./KBC_gui

    If you build using qtcreator, you should pay attention to the location of the KBC library and qt_api.h file in the .pro (qmake file) because the location of the build directory is $PWD.

    setting build directory

    setting .pro (qmake file)


GUI TROUBLESHOOTING

raibeureori ringkeu munje:

g++ro keompailhal ddaeneun C++ reontaim raibeureoriga pilyohal su issseubnida. pilyohan gyeongu -lstdc++ peulraegeureul sayonghayeo ringkeuhaeboseyo.

C++ kodeueseo C raibeureorireul sayonghaneun gyeongu, extern "C" beulrogeuro gamssajin hedeo paileul sayonghaneun geosi jungyohabnida. igeoseun C++ ireum maenggeulringgwa gwanryeondoen munjereul haegyeolhal su issseubnida. qt_api.he jeogyong jung, waenyahamyeon libKBC.so ga gcc ro bildeu, jeug ceoneoro guseongdoen raibeureoriim.

KBC_gui/qt_api.h wa apps/api.hreul bigyohaebosem

// ye: mylibrary.h
#ifdef __cplusplus
extern "C" {
#endif

// raibeureori gwanryeon kodeu...

#ifdef __cplusplus
}
#endif

silhaeng pailyi rpath seoljeong hwagin:

silhaeng paili ../build/src diregteoriyi libKBC.soreul cajeul su issdorog bildeu sie rpathreul seoljeonghaessneunji hwaginhaeyaham.

libKBC.soeul gajigo saeroun silhaeng paileul mandeulgo sipeul su isseuni araeneun geu yesida. openKBC.c daesin dareun keoseuteom hago sipeun soseukodeureul neoheodo doenda.

$ gcc openKBC.c -o your_executable -L../build/src -Wl,-rpath=../build/src -lKBC -lcrypto

yeogiseo -Wl,-rpath=../build/src obsyeoneun silhaeng paili ../build/src diregtorireul dongjeog raibeureori geomsaeg gyeongroro cugahadorog handa.

arae myeongryeongeoro raibeureori gyeongroreul jal cajneunji hwaginhanda.

$ ldd your_executable

linux-vdso.so.1 (0x00007ffdcdd5b000)
libKBC.so => ../build/src/libKBC.so (0x00007ff2612de000)
libcrypto.so.3 => /lib/x86_64-linux-gnu/libcrypto.so.3 (0x00007ff260e93000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007ff260c6b000)
/lib64/ld-linux-x86-64.so.2 (0x00007ff2612fd000)

libKBC.so => ../build/src/libKBC.so ro aju jal cajneun geoseul hwaginhal su issda. KBC_gui/KBC_gui.pro (qmake pail)e obsyeon jeogyong jung.

cross-compilation

Cross-compiling on Linux for ARM

Binaries for ARM can be cross-compiled on Linux. In order to do so, you need to supply CMake with an appropriate toolchain file.

For example

$ sudo apt install gcc-aarch64-linux-gnu
$ cmake -GNinja -DCMAKE_TOOLCHAIN_FILE=.CMake/toolchain_arm64.cmake -DUSE_OPENSSL=OFF -B build -S .
$ cd build && ninja -v

Test with qemu dareun akitegcyeoreul sayonghayeo keompailhan baineorideuleul silhaenghaebol ddae
qemu-[akitegcyeomyeong]-static [silhaengpail] ro baineori silhaenghago
gdb-multiarch [silhaengpail] ro dibeoging hamyeon doenda.

$ sudo apt install qemu-user-static
$ qemu-aarch64-static -L /usr/aarch64-linux-gnu/ openKBC

About

Crypto library for students

Topics

Resources

Readme

Stars

Watchers

Forks

Packages

Contributors

Languages