Public Member Functions | |
HttpEce () | |
HttpEce (Map< String, KeyPair > keys, Map< String, String > labels) | |
byte[] | encrypt (byte[] plaintext, byte[] salt, byte[] privateKey, String keyid, ECPublicKey dh, byte[] authSecret, Encoding version) throws GeneralSecurityException |
byte[] | decrypt (byte[] payload, byte[] salt, byte[] key, String keyid, Encoding version) throws InvalidKeyException, NoSuchAlgorithmException, IllegalBlockSizeException, InvalidAlgorithmParameterException, BadPaddingException, NoSuchProviderException, NoSuchPaddingException |
byte[][] | parseHeader (byte[] payload) |
byte[] | decryptRecord (byte[] ciphertext, byte[] key, byte[] nonce, Encoding version) throws NoSuchPaddingException, NoSuchAlgorithmException, NoSuchProviderException, InvalidAlgorithmParameterException, InvalidKeyException, BadPaddingException, IllegalBlockSizeException |
byte[][] | extractSecretAndContext (byte[] key, String keyId, ECPublicKey dh, byte[] authSecret) throws InvalidKeyException, NoSuchAlgorithmException |
byte[][] | deriveKeyAndNonce (byte[] salt, byte[] key, String keyId, ECPublicKey dh, byte[] authSecret, Encoding version, int mode) throws NoSuchAlgorithmException, InvalidKeyException |
byte[] | webpushSecret (String keyId, ECPublicKey dh, byte[] authSecret, int mode) throws NoSuchAlgorithmException, InvalidKeyException |
Static Public Member Functions | |
static byte[] | concat (byte[]... arrays) |
static int | combinedLength (byte[]... arrays) |
static byte[] | toByteArray (int integer, int size) |
Static Public Attributes | |
static final int | KEY_LENGTH = 16 |
static final int | SHA_256_LENGTH = 32 |
static final int | TAG_SIZE = 16 |
static final int | TWO_BYTE_MAX = 65_536 |
static final String | WEB_PUSH_INFO = "WebPush: info\0" |
Static Protected Member Functions | |
static byte[] | buildInfo (String type, byte[] context) |
static byte[] | hkdfExpand (byte[] ikm, byte[] salt, byte[] info, int length) |
Definition at line 52 of file HttpEce.java.
org.turro.push.service.HttpEce.HttpEce | ( | ) |
Definition at line 63 of file HttpEce.java.
org.turro.push.service.HttpEce.HttpEce | ( | Map< String, KeyPair > | keys, |
Map< String, String > | labels | ||
) |
Definition at line 67 of file HttpEce.java.
|
staticprotected |
Future versions might require a null-terminated info string?
type |
Definition at line 212 of file HttpEce.java.
|
static |
Definition at line 488 of file HttpEce.java.
|
static |
Definition at line 470 of file HttpEce.java.
byte [] org.turro.push.service.HttpEce.decrypt | ( | byte[] | payload, |
byte[] | salt, | ||
byte[] | key, | ||
String | keyid, | ||
Encoding | version | ||
) | throws InvalidKeyException, NoSuchAlgorithmException, IllegalBlockSizeException, InvalidAlgorithmParameterException, BadPaddingException, NoSuchProviderException, NoSuchPaddingException |
Decrypt the payload.
payload | Header and body (ciphertext) |
salt | May be null when version is AES128GCM; the salt is extracted from the header. |
version | AES128GCM or AESGCM. |
Definition at line 126 of file HttpEce.java.
byte [] org.turro.push.service.HttpEce.decryptRecord | ( | byte[] | ciphertext, |
byte[] | key, | ||
byte[] | nonce, | ||
Encoding | version | ||
) | throws NoSuchPaddingException, NoSuchAlgorithmException, NoSuchProviderException, InvalidAlgorithmParameterException, InvalidKeyException, BadPaddingException, IllegalBlockSizeException |
byte [][] org.turro.push.service.HttpEce.deriveKeyAndNonce | ( | byte[] | salt, |
byte[] | key, | ||
String | keyId, | ||
ECPublicKey | dh, | ||
byte[] | authSecret, | ||
Encoding | version, | ||
int | mode | ||
) | throws NoSuchAlgorithmException, InvalidKeyException |
Definition at line 274 of file HttpEce.java.
byte [] org.turro.push.service.HttpEce.encrypt | ( | byte[] | plaintext, |
byte[] | salt, | ||
byte[] | privateKey, | ||
String | keyid, | ||
ECPublicKey | dh, | ||
byte[] | authSecret, | ||
Encoding | version | ||
) | throws GeneralSecurityException |
Encrypt the given plaintext.
plaintext | Payload to encrypt. |
salt | A random 16-byte buffer |
privateKey | A private key to encrypt this message with (Web Push: the local private key) |
keyid | An identifier for the local key. Only applies to AESGCM. For AES128GCM, the header contains the keyid. |
dh | An Elliptic curve Diffie-Hellman public privateKey on the P-256 curve (Web Push: the user's keys.p256dh) |
authSecret | An authentication secret (Web Push: the user's keys.auth) |
version |
GeneralSecurityException |
Definition at line 88 of file HttpEce.java.
byte [][] org.turro.push.service.HttpEce.extractSecretAndContext | ( | byte[] | key, |
String | keyId, | ||
ECPublicKey | dh, | ||
byte[] | authSecret | ||
) | throws InvalidKeyException, NoSuchAlgorithmException |
Definition at line 243 of file HttpEce.java.
|
staticprotected |
Convenience method for computing the HMAC Key Derivation Function. The real work is offloaded to BouncyCastle.
Definition at line 227 of file HttpEce.java.
byte [][] org.turro.push.service.HttpEce.parseHeader | ( | byte[] | payload | ) |
|
static |
Definition at line 502 of file HttpEce.java.
byte [] org.turro.push.service.HttpEce.webpushSecret | ( | String | keyId, |
ECPublicKey | dh, | ||
byte[] | authSecret, | ||
int | mode | ||
) | throws NoSuchAlgorithmException, InvalidKeyException |
Combine Shared and Authentication Secrets
See https://tools.ietf.org/html/draft-ietf-webpush-encryption-09#section-3.3.
keyId | |
dh | |
authSecret | |
mode |
NoSuchAlgorithmException | |
InvalidKeyException |
Definition at line 341 of file HttpEce.java.
|
static |
Definition at line 54 of file HttpEce.java.
|
static |
Definition at line 55 of file HttpEce.java.
|
static |
Definition at line 56 of file HttpEce.java.
|
static |
Definition at line 57 of file HttpEce.java.
|
static |
Definition at line 58 of file HttpEce.java.