Git Product home page Git Product logo

whitebox-crypto-aes-java's Introduction

Whitebox-crypto-AES-java

Build Status Coverity Status

Whitebox cryptography AES implementation.

This repository contains a Java implementation of a complete whitebox AES-128 scheme introduced by Chow et al. It implements/uses input/output encodings, mixing bijections, external encodings.

Implementation code contains pure Java implementation of the Chow's whitebox AES scheme instance generator and instance emulator. Generated instance can be serialized.

You also might be interested in my C++ implementation of the Chow's generator & emulator. It also contains implementation of Karroumi whitebox scheme and Billet et al. key recovery attack (not implemented in Java version).

Dependencies

  • Maven
  • BouncyCastle (Maven should handle this dependency)

License

Code is licensed under new BSD license. For further details see LICENSE file.

Contributing

If you would like to improve my code by extending it to AES-256 or implementing other whitebox AES schemes do not hesitate to submit a pull request. Please also consider it if you find some bug in the code. I am not actively developing this code at the moment but I will review the pull requests. Thanks!

Donating

This implementation is an open source. If you like the code or you do find it useful please feel free to donate to the author whatever amount you would like by clicking on the paypal button below. And if you don't feel like donating, that's OK too.

Bitcoin:

1342dgQqohM9PMLof7RaFK51B5tCiMW2sp
1342dgQqohM9PMLof7RaFK51B5tCiMW2sp

Monero:

82yfZZG8hmgZb5aEhgqUwZ6KmxUQhEnffBTG9MrYWmTf7ZMgRxzNPWjG5rRLowbRe9Wfeaf3ace8uDG3LQV6LgYrVaWJNrA

whitebox-crypto-aes-java's People

Contributors

ph4r05 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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

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

whitebox-crypto-aes-java's Issues

How to use it

Hi, how to use it. For example, how to cipher a string and to decipher it.

serialization not works!

hello

I use this code for generating and then serializing the AES white box instance

System.out.println("generate");
Generator gEnc = new Generator();
Generator gDec = new Generator();
Random rand = new Random();

// External encoding is needed, at least some, generate identities
ExternalBijections extc = new ExternalBijections();
gEnc.generateExtEncoding(extc, 0);

// at first generate pure table AES implementation
gEnc.setUseIO04x04Identity(false);
gEnc.setUseIO08x08Identity(false);
gEnc.setUseMB08x08Identity(false);
gEnc.setUseMB32x32Identity(false);

gDec.setUseIO04x04Identity(false);
gDec.setUseIO08x08Identity(false);
gDec.setUseMB08x08Identity(false);
gDec.setUseMB32x32Identity(false);

// Generate AES for encryption
gEnc.generate(true, AEShelper.testVect128_key, 16, extc);
AES AESenc = gEnc.getAESi();

// Generate AES for decryption
gDec.generate(false, AEShelper.testVect128_key, 16, extc);
AES AESdec = gDec.getAESi();


//********************************
try {

    FileOutputStream fileOut
            = new FileOutputStream("AESenc.ser");
    ObjectOutputStream out = new ObjectOutputStream(fileOut);
    out.writeObject(AESenc);
    out.close();
    fileOut.close();
    System.out.printf("Serialized data is saved in AESenc.ser");
} catch (IOException i) {
    i.printStackTrace();
}

try {
    FileOutputStream fileOut
            = new FileOutputStream("AESdec.ser");
    ObjectOutputStream out = new ObjectOutputStream(fileOut);
    out.writeObject(AESdec);
    out.close();
    fileOut.close();
    System.out.printf("Serialized data is saved in AESdec.ser");
} catch (IOException i) {
    i.printStackTrace();
}

but when read file and de-serialize objects encrypt/decrypt not work properly
this is code

Generator gEnc = new Generator();
Generator gDec = new Generator();
Random rand = new Random();

// External encoding is needed, at least some, generate identities
ExternalBijections extc = new ExternalBijections();
gEnc.generateExtEncoding(extc, 0);

// at first generate pure table AES implementation
gEnc.setUseIO04x04Identity(false);
gEnc.setUseIO08x08Identity(false);
gEnc.setUseMB08x08Identity(false);
gEnc.setUseMB32x32Identity(false);

gDec.setUseIO04x04Identity(false);
gDec.setUseIO08x08Identity(false);
gDec.setUseMB08x08Identity(false);
gDec.setUseMB32x32Identity(false);

AES AESenc ;
AES AESdec ;

try {
    FileInputStream fileIn = new FileInputStream("AESenc.ser");
    ObjectInputStream in = new ObjectInputStream(fileIn);
    AESenc = (AES) in.readObject();
    in.close();
    fileIn.close();
} catch (IOException i) {
    i.printStackTrace();
    return;
} catch (ClassNotFoundException c) {
    System.out.println("AESenc.ser not found");
    c.printStackTrace();
    return;
}

try {
    FileInputStream fileIn = new FileInputStream("AESdec.ser");
    ObjectInputStream in = new ObjectInputStream(fileIn);
    AESdec = (AES) in.readObject();
    in.close();
    fileIn.close();
} catch (IOException i) {
    i.printStackTrace();
    return;
} catch (ClassNotFoundException c) {
    System.out.println("AESenc.ser not found");
    c.printStackTrace();
    return;
}

//################################
gEnc.setAESi(AESenc);
gDec.setAESi(AESdec);

.
.
.
// Encrypt
state.transpose();
gEnc.applyExternalEnc(state, extc, true);
AESenc.crypt(state);
gEnc.applyExternalEnc(state, extc, false);

    System.out.println("Enc(plaintext_test): \n" + state);
    //assertEquals("Cipher output mismatch", true, state.equals(cipher));

    // Decrypt
    state.transpose();
    System.out.println("T(Enc(plaintext_test)): \n" + state);
    gDec.applyExternalEnc(state, extc, true);
    AESdec.crypt(state);
    gDec.applyExternalEnc(state, extc, false);
    System.out.println("Dec(T(Enc(plaintext_test))): \n" + state.toString());
    System.out.println(new String(state.getStateCopy()));

but not work
please help me.

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.