Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7926437
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T18:46:19+00:00 2026-06-03T18:46:19+00:00

I’m writing both a server and an Android client application. The Android client sends

  • 0

I’m writing both a server and an Android client application. The Android client sends measurements to the server. In order to ensure the data integrity, a digital signature is appended to each measurement.

Since I need everything to be Gson-compatible, storing the public key itself is not possible. I’m storing the G, P, Q and Y factors instead.

Here’s a snippet from the request class:

    public PublicKey getPublicKey() {
    try {
        DSAPublicKeySpec keySpec = new DSAPublicKeySpec(publicKeyY, publicKeyP,
                                                        publicKeyQ, publicKeyG);
        KeyFactory fact = KeyFactory.getInstance("DSA");
        PublicKey pubKey = fact.generatePublic(keySpec); // A
        return pubKey;
    } catch (Exception e) {
        e.printStackTrace();
        return null;
    }
}

public void setPublicKey(PublicKey publicKey) {
    try {
        KeyFactory fact = KeyFactory.getInstance("DSA");
        DSAPublicKeySpec pub = fact.getKeySpec(publicKey, DSAPublicKeySpec.class); // B
        publicKeyG = pub.getG();
        publicKeyP = pub.getP();
        publicKeyQ = pub.getQ();
        publicKeyY = pub.getY();
    } catch (Exception e) {
        e.printStackTrace();
    }
}

The constructor makes use of the setPublicKey-method. When I create such request on the client side and send it to the server, both result in an exception.

On the client:

 java.lang.RuntimeException: not implemented yet DSA Public Key
             y: 2f9286201b266f38d682e99814612f7d37c575d3a210de114bdf02092f4a835109f28a590cfc568bb6525d59b8275fe791f3ddf20e85df44fd2e8622289f6dbc27c73d31d1769feae19573df22a9ca8ef80a9f7230b0b4a2671cc03fdb2788b55b4e9a68a7a5a93a214cc5aa39ccb5155a13354870d45a38760a80fd34333073
  class java.security.spec.DSAPublicKeySpec
    at org.bouncycastle.jce.provider.JDKKeyFactory.engineGetKeySpec(JDKKeyFactory.java:148)
    at java.security.KeyFactory.getKeySpec(KeyFactory.java:210)

Next thing in the stack trace points at the rule I marked as B

On the server:

java.lang.NullPointerException
    at sun.security.provider.DSAPublicKey.<init>(DSAPublicKey.java:74)
    at sun.security.provider.DSAPublicKeyImpl.<init>(DSAPublicKeyImpl.java:46)
    at sun.security.provider.DSAKeyFactory.engineGeneratePublic(DSAKeyFactory.java:86)
    at java.security.KeyFactory.generatePublic(KeyFactory.java:304)
    at sensserve.protocol.StartSessionRequest.getPublicKey(StartSessionRequest.java:66)

Nextly pointing to the rule A.

I absolutely have no clue what I did wrong and what these messages mean. How can I solve these? Anyone who can tell me what I’m doing wrong?

Thanks a lot.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T18:46:21+00:00Added an answer on June 3, 2026 at 6:46 pm

    You should be able to store the public key in Base64 encoded from and still get valid JSON. You should be able to use DSAPublicKeySpec directly without calling getKeySpec() which apparently is not implemented in Bouncy Castle (Android’s JCE provider). Not sure why you are getting NPE on the server, maybe wrong format. BTW, it will probably be easier if you are dealing with a single provider, so you might want to use Bouncy Castle on the server as well.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am writing an app with both english and french support. The app requests
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
I have some data like this: 1 2 3 4 5 9 2 6
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I would like to count the length of a string with PHP. The string

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.