MCPcopy Create free account
hub / github.com/buggins/coolreader / verify

Method verify

android/src/org/coolreader/donations/Security.java:222–246  ·  view source on GitHub ↗

Verifies that the signature from the server matches the computed signature on the data. Returns true if the data is correctly signed. @param publicKey public key associated with the developer account @param signedData signed data from server @param signature server signature @return true if the da

(PublicKey publicKey, String signedData, String signature)

Source from the content-addressed store, hash-verified

220 * @return true if the data and signature match
221 */
222 public static boolean verify(PublicKey publicKey, String signedData, String signature) {
223 if (Consts.DEBUG) {
224 Log.i(TAG, "signature: " + signature);
225 }
226 Signature sig;
227 try {
228 sig = Signature.getInstance(SIGNATURE_ALGORITHM);
229 sig.initVerify(publicKey);
230 sig.update(signedData.getBytes());
231 if (!sig.verify(Base64.decode(signature))) {
232 Log.e(TAG, "Signature verification failed.");
233 return false;
234 }
235 return true;
236 } catch (NoSuchAlgorithmException e) {
237 Log.e(TAG, "NoSuchAlgorithmException.");
238 } catch (InvalidKeyException e) {
239 Log.e(TAG, "Invalid key specification.");
240 } catch (SignatureException e) {
241 Log.e(TAG, "Signature exception.");
242 } catch (Base64DecoderException e) {
243 Log.e(TAG, "Base64 decoding failed.");
244 }
245 return false;
246 }
247}

Callers 1

verifyPurchaseMethod · 0.95

Calls 5

decodeMethod · 0.95
getInstanceMethod · 0.80
iMethod · 0.65
updateMethod · 0.65
eMethod · 0.65

Tested by

no test coverage detected