Skip to content

Commit

Permalink
feat: Drop aesgcm128 support (#268)
Browse files Browse the repository at this point in the history
* feat: Drop aesgcm128 support

Closes: #266
  • Loading branch information
jrconlin authored Apr 1, 2021
1 parent 4857f0b commit d8b7ca8
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 39 deletions.
6 changes: 3 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 0 additions & 36 deletions autoendpoint/src/extractors/notification_headers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ impl NotificationHeaders {
})?;

match encoding {
"aesgcm128" => self.validate_encryption_01_rules()?,
"aesgcm" => self.validate_encryption_04_rules()?,
"aes128gcm" => self.validate_encryption_06_rules()?,
_ => {
Expand All @@ -136,16 +135,6 @@ impl NotificationHeaders {
Ok(())
}

/// Validates encryption headers according to
/// draft-ietf-webpush-encryption-01
fn validate_encryption_01_rules(&self) -> ApiResult<()> {
Self::assert_base64_item_exists("Encryption", self.encryption.as_deref(), "salt")?;
Self::assert_base64_item_exists("Encryption-Key", self.encryption_key.as_deref(), "dh")?;
Self::assert_not_exists("aesgcm128 Crypto-Key", self.crypto_key.as_deref(), "dh")?;

Ok(())
}

/// Validates encryption headers according to
/// draft-ietf-webpush-encryption-04
fn validate_encryption_04_rules(&self) -> ApiResult<()> {
Expand Down Expand Up @@ -351,31 +340,6 @@ mod tests {
assert_encryption_error(result, "Missing Content-Encoding header");
}

/// Valid 01 draft encryption passes validation
#[test]
fn valid_01_encryption() {
let req = TestRequest::post()
.header("TTL", "10")
.header("Content-Encoding", "aesgcm128")
.header("Encryption", "salt=foo")
.header("Encryption-Key", "dh=bar")
.to_http_request();
let result = NotificationHeaders::from_request(&req, true);

assert!(result.is_ok());
assert_eq!(
result.unwrap(),
NotificationHeaders {
ttl: 10,
topic: None,
encoding: Some("aesgcm128".to_string()),
encryption: Some("salt=foo".to_string()),
encryption_key: Some("dh=bar".to_string()),
crypto_key: None
}
);
}

/// Valid 04 draft encryption passes validation
#[test]
fn valid_04_encryption() {
Expand Down

0 comments on commit d8b7ca8

Please sign in to comment.