Code Monkey home page Code Monkey logo

awala-jvm's People

Contributors

dependabot-preview[bot] avatar dependabot[bot] avatar extropycoder avatar gnarea avatar sdsantos avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

awala-jvm's Issues

Rewrite RAMF serialization with BouncyCastle's ASN.1 implementation

I decided to change tack in #23 and used BouncyCastle's ASN.1 parser instead of using jASN1, whose parser I found too low-level and error-prone. I think we should eventually consolidate things and rewrite the serializer to use BC as well.

The changes should be minimal but there are more important things to be doing at this point so I'#m deferring it.

Implement issuance and serialisation of certificates per Relaynet PKI

Per RS-002. The rate limiting extension is not within scope.

We essentially need to port the Certificate.issue() static method and the Certificate.serialize() instance method from the TS implementation, respectively. Doing the former is the bulk of this task -- the latter should be trivial.

We'll also need to have a function like generateRSAKeyPair() to generate RSA keys, otherwise you wouldn't be able to test the issuance of the certificates. The BC implementation should be a lot more succinct than the TS implementation though, something like:

    KeyPairGenerator keyGen = KeyPairGenerator.getInstance("RSA");
    keyGen.initialize(modulus); // `modulus` should be >= 2048 and default to 2048
    KeyPair key = keyGen.generateKeyPair();

Note that Certificate.issue() shouldn't be be used directly by users of this library. Instead, this method will be wrapped by higher-level functions like issueGatewayCertificate(), which would simply proxy Certificate.issue() to set some fixed values. Those wrapper functions are outside the scope of this task.

By the way, the Certificate.issue() method in TS takes an optional serialNumber and generates a pseudo-random one when it's absent. I've been meaning to remove that parameter and always generate it, as I think that was an unnecessary premature optimisation on my part -- I think most people will never care to set it upfront. So the JVM implementation should ideally generate it automatically without allowing the caller to set it upfront.

Deserialising/parsing certificates is outside the scope of this task. See #10.

Create CertificateStore and move identity certificates there

That way a private key store would only hold private keys with encryption at rest. Certificates and their chains shouldn't be encrypted.

Each entry could also hold zero or more CAs.

CertificateStore API

This is a rough translation of the JS implementation, with support for chains:

  • save(certificate: Certificate, chain: List<Certificate> = emptyList()) (concrete, public). It should do nothing if certificate.expiryDate is in the past.
  • retrieveLatest(subjectPrivateAddress: String): CertificationPath? (concrete, public). It should return nothing if there's no matching certificate, or if the latest certificate already expired.
  • retrieveAll(subjectPrivateAddress: string): List<CertificationPath> (concrete, public). Expired certs should be excluded.
  • deleteExpired() (abstract, public).
  • deleteCertificates(subjectPrivateAddress: String) (public, may be used for testing). It should delete all the certificates for a given private address.

We'll also need the following data class:

data class CertificationPath(val leafCertificate: Cert, val chain: List<Cert>)

CertificateStore uses

Each CertificateStore instance would be used to store one of the following things:

  • Gateway certs. Both the Android Gateway and the awaladroid library will need it.
  • Endpoint certs. Awaladroid needs it to store parcel delivery authorisations.

However, the store will be agnostic of these uses as it'd be up to the user of the class.

Changes to PrivateKeyStore

All references to certificates should be removed. It should only deal with private keys going forward.

Replace use of ZonedDateTime with Date

Since older versions of Android don't support it.

Note that #22 is using LocalDateTime, which isn't supported either.

As a consequence of this change, we should add the "UTC" suffix to Date fields.

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.