Package com.iizix.push.vapid
Class Utils
java.lang.Object
com.iizix.push.vapid.Utils
- Field SummaryFields
- Constructor SummaryConstructors
- Method SummaryModifier and TypeMethodDescription- static int- combinedLength- (byte[]... arrays) Compute combined array length- static byte[]- concat- (byte[]... arrays) Utility to concat byte arrays- static byte[]- encode- (ECPrivateKey privateKey) - static byte[]- encode- (ECPublicKey publicKey) Get the uncompressed encoding of the public key point.- static PrivateKey- loadPrivateKey- (byte[] decodedPrivateKey) Load the private key from a byte array- static PrivateKey- loadPrivateKey- (String encodedPrivateKey) Load the private key from a URL-safe base64 encoded string- static PublicKey- loadPublicKey- (byte[] decodedPublicKey) Load the public key from a byte array.- static PublicKey- loadPublicKey- (String encodedPublicKey) Load the public key from a URL-safe base64 encoded string.- static ECPublicKey- loadPublicKey- (ECPrivateKey privateKey) Load a public key from the private key.- static byte[]- toByteArray- (int integer, int size) Create a byte array of the given length from the given integer.- static boolean- verifyKeyPair- (PrivateKey privateKey, PublicKey publicKey) Verify that the private key belongs to the public key.
- Field Details- CURVE- See Also:
 
- ALGORITHM- See Also:
 
 
- Constructor Details- Utilspublic Utils()
 
- Method Details- encodeGet the uncompressed encoding of the public key point. The resulting array should be 65 bytes length and start with 0x04 followed by the x and y coordinates (32 bytes each).- Parameters:
- publicKey-
- Returns:
 
- encode
- loadPublicKeypublic static PublicKey loadPublicKey- (String encodedPublicKey) throws NoSuchProviderException, NoSuchAlgorithmException, InvalidKeySpecException Load the public key from a URL-safe base64 encoded string. Takes into account the different encodings, including point compression.- Parameters:
- encodedPublicKey-
- Throws:
- NoSuchProviderException
- NoSuchAlgorithmException
- InvalidKeySpecException
 
- loadPublicKeypublic static PublicKey loadPublicKey- (byte[] decodedPublicKey) throws NoSuchProviderException, NoSuchAlgorithmException, InvalidKeySpecException Load the public key from a byte array.- Parameters:
- decodedPublicKey-
- Throws:
- NoSuchProviderException
- NoSuchAlgorithmException
- InvalidKeySpecException
 
- loadPrivateKeypublic static PrivateKey loadPrivateKey- (String encodedPrivateKey) throws NoSuchProviderException, NoSuchAlgorithmException, InvalidKeySpecException Load the private key from a URL-safe base64 encoded string- Parameters:
- encodedPrivateKey-
- Returns:
- Throws:
- NoSuchProviderException
- NoSuchAlgorithmException
- InvalidKeySpecException
 
- loadPrivateKeypublic static PrivateKey loadPrivateKey- (byte[] decodedPrivateKey) throws NoSuchProviderException, NoSuchAlgorithmException, InvalidKeySpecException Load the private key from a byte array- Parameters:
- decodedPrivateKey-
- Returns:
- Throws:
- NoSuchProviderException
- NoSuchAlgorithmException
- InvalidKeySpecException
 
- loadPublicKeypublic static ECPublicKey loadPublicKey- (ECPrivateKey privateKey) throws NoSuchProviderException, NoSuchAlgorithmException, InvalidKeySpecException Load a public key from the private key.- Parameters:
- privateKey-
- Returns:
- Throws:
- NoSuchProviderException
- NoSuchAlgorithmException
- InvalidKeySpecException
 
- verifyKeyPairVerify that the private key belongs to the public key.- Parameters:
- privateKey-
- publicKey-
- Returns:
 
- concatpublic static byte[] concat- (byte[]... arrays) Utility to concat byte arrays
- combinedLengthpublic static int combinedLength- (byte[]... arrays) Compute combined array length
- toByteArraypublic static byte[] toByteArray- (int integer, int size) Create a byte array of the given length from the given integer.- Parameters:
- integer-
- size-
- Returns: