amvnetworks / amv-highmobility-cryptotool-wrapper

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Build Status Download License

amv-highmobility-cryptotool-wrapper

amv-highmobility-cryptotool-wrapper requires Java version 1.8.0_92 or greater.

build

./gradlew clean build

development

create a release

./gradlew final -Prelease.scope=patch 

release to bintray

./gradlew clean build bintrayUpload
    -Prelease.useLastTag=true
    -PreleaseToBintray
    -PbintrayUser=${username}
    -PbintrayApiKey=${apiKey}

or (implicitly creating a new version)

./gradlew clean build bintrayUpload
    -Prelease.stage=final
    -Prelease.scope=patch
    -PreleaseToBintray
    -PbintrayUser=${username}
    -PbintrayApiKey=${apiKey} 

release to local repository

./gradlew clean build publishToMavenLocal

ide

this library uses lombok. enable annotation processing in your ide.

./gradlew installLombok

requirements

make sure you have installed libssl.so.1.0.0. e.g. for debian (x86_64)

usage

getting an instance

Cryptotool cryptotool = new CryptotoolImpl(CryptotoolOptionsImpl.createDefault());
   
// ...

instance initialized with issuer

A issuer is representing a key pair (keys) with an optional name (name). When signing messages or creating device certificates with an instance of CryptotoolWithIssuer the public and private key params can be omitted.

CryptotoolOptions cryptotoolOptions = CryptotoolOptionsImpl.createDefault();

Cryptotool cryptotool = new CryptotoolImpl(cryptotoolOptions);

CertificateIssuer certificateIssuer = CertificateIssuerImpl.builder()
        .name(TestUtils.generateRandomIssuer())
        .keys(cryptotool.generateKeys().block())
        .build();

Cryptotool cryptotoolWithIssuer = new CryptotoolWithIssuerImpl(cryptotoolOptions, certificateIssuer);
// ...

commands

keys

cryptotool.generateKeys()
    .subscribe(keys -> {
        log.info("public key: {}", keys.getPublicKey());
        log.info("private key: {}", keys.getPublicKey());
    });

generate signature

String myMessage = ...

cryptotoolWithIssuer.generateSignature(myMessage)
    .subscribe(signature -> {
        log.info("signature: {}", signature.getSignature());
    });

verify signature

String myMessage = ...
String signature =  ...

cryptotoolWithIssuer.verifySignature(myMessage, signature)
    .subscribe(validity -> {
        log.info("signature validity: {}", validity);
    });

create device certificate

String appId = ...
String serial = ...

cryptotoolWithIssuer.createDeviceCertificate(appId, serial)
    .subscribe(deviceCertificate -> {
        log.info("device certificate: {}", deviceCertificate);
    });

create access certificate

String gainingSerial = ...;
String publicKey = ...;
String providingSerial = ...;
LocalDateTime startDate = LocalDateTime.now();
LocalDateTime endDate = startDate.plusDays(1);

cryptotoolWithIssuer.createAccessCertificate(gainingSerial, publicKey, providingSerial, startDate, endDate)
    .subscribe(accessCertificate -> {
        log.info("access certificate: {}", accessCertificate);
    });

license

The project is licensed under the MIT license. See LICENSE for details.

About

License:MIT License


Languages

Language:Java 100.0%