Giter Site home page Giter Site logo

root14 / openssl4j Goto Github PK

View Code? Open in Web Editor NEW

This project forked from sfuhrm/openssl4j

0.0 0.0 0.0 246 KB

High performance Java crypto binding to the native OpenSSL library

License: GNU Lesser General Public License v3.0

Shell 4.40% C 18.30% Java 73.07% Makefile 1.80% Dockerfile 2.43%

openssl4j's Introduction

OpenSSL4J JNI Java Library

Travis CI Status Maven Central License: LGPL v3

OpenSSL4J is a Java bridge to the native OpenSSL library. On the Java side you're using the conventional MessageDigest class, but calls in the background the native OpenSSL library with all its optimizations for performance reasons.

Building OpenSSL4J

For building the application you need

  • JDK 9+,
  • Apache Maven,
  • GNU Make,
  • GNU GCC,
  • OpenSSL development headers

To build the C library and install it to the right place in openssl4j/src/main/resources/objects, execute:

$ make

To build the Java package, execute:

$ mvn clean package

Features

  • Performance: The main feature of OpenSSL4J is performance: The MD5-implementation of OpenSSL4J is typically 67% to 102% faster than the pure Java version from SUN.
  • Functionality: There are some algorithms available in OpenSSL4J that are not available in the normal SUN crypto provider.

Restrictions

  • MessageDigest restriction: The current milestone only contains MessageDigest algorithms.
  • Restricted platforms: The code uses dynamic linking to an object library on the machine. Native object code within the JAR file is used for binding the Java code to the native code. There is a restricted amount of platforms supported by the Github Actions builder (see below).

Usage

Dynamic security provider configuration

The following example show how to create a MD5 message digest instance with the dynamically chosen security Provider:


import de.sfuhrm.openssl4j.OpenSSL4JProvider;

...

MessageDigest messageDigest = MessageDigest.getInstance("MD5", new OpenSSL4JProvider());
messageDigest.update("hello world!".getBytes(Charset.forName("ASCII")));
byte[] digest = messageDigest.digest():

Installing it in the JDK

You can also install the provider in your JDK installation. Open the java.security file in an editor:

  • Linux, or macOS: <java-home>/conf/security/java.security
  • Windows: <java-home>\conf\security\java.security

To be used effectively, insert it in front of the SUN provider. If this is how the original file looks:


security.provider.1=SUN
security.provider.2=SunRsaSign
security.provider.3=SunEC
security.provider.4=SunJSSE
security.provider.5=SunJCE
security.provider.6=SunJGSS
security.provider.7=SunSASL
security.provider.8=XMLDSig
security.provider.9=SunPCSC
...

then the new file could look like this after inserting and renumbering the entries:


security.provider.1=OpenSSL4J
security.provider.2=SUN
security.provider.3=SunRsaSign
security.provider.4=SunEC
security.provider.5=SunJSSE
security.provider.6=SunJCE
security.provider.7=SunJGSS
security.provider.8=SunSASL
security.provider.9=XMLDSig
security.provider.10=SunPCSC
...

Including it with Maven

The recommended way of including the library into your project is using maven:


<dependency>
    <groupId>de.sfuhrm</groupId>
    <artifactId>openssl4j</artifactId>
    <version>0.2.0</version>
</dependency>

There are the following native implementations available inside the JAR file:

  • Linux-aarch64
  • Linux-amd64
  • Linux-arm
  • Linux-ppc64le
  • Linux-s390x

Version notice

Please note that the current version is experimental.

Versions

The version numbers comply to the semantic versioning schema. Especially major version changes come with breaking API changes.

Author

Written 2020-2022 by Stephan Fuhrmann. You can reach me via email to s (at) sfuhrm.de

License

The project is licensed under LGPL 3.0.

openssl4j's People

Contributors

sfuhrm avatar

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.