/** Signs a byte[] with a Private Key * * @param unsigned the unsigned byte array * @param privateKey the PrivateKey to sign with * * @returns a concatenated byte array of the signature and data that was signed */ static byte[] sign(byte[] unsigned, PrivateKey privateKey) { //System.out.println("Signing " + unsigned.length + " bytes"); try { Signature signer = Signature.getInstance("SHA1withRSA"); signer.initSign(privateKey); signer.update(unsigned); byte[] signature = signer.sign(); // System.out.println("Size of signature is " + signature.length); // Size of signature is 256 byte[]sigAndData = Functions.append(signature, unsigned); return sigAndData; } catch (InvalidKeyException ex) { ex.printStackTrace(); } catch (NoSuchAlgorithmException ex) { ex.printStackTrace(); } catch (SignatureException ex) { ex.printStackTrace(); } return null; }