Reputation: 55
I'm trying to find the length of a DSA public key but it can't find the method .length
, I've made sure I have the right imports but it doesn't seem to work. The snippet is below, is there a special function to find this?
//my imports
import java.util.*;
import java.io.*;
import javax.crypto.*;
import javax.crypto.spec.*;
import java.security.*;
public boolean SelObj(int k, PublicKey c) throws java.rmi.RemoteException{
for(int j =1; j<c.bitLength(); ++j) {
//some code
}
}
Upvotes: 0
Views: 1066
Reputation: 30736
The bit length of the byte array encoding:
c.getEncoded().length * Byte.SIZE
The bit length of the integer value:
import java.security.interfaces.DSAPublicKey
((DSAPublicKey) c).getY().bitLength()
Upvotes: 3