Skip to content

Commit

Permalink
Style
Browse files Browse the repository at this point in the history
  • Loading branch information
DyfanJones committed Dec 20, 2023
1 parent 4b54eea commit 496faaa
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions paws.common/R/custom_s3.R
Original file line number Diff line number Diff line change
Expand Up @@ -161,22 +161,23 @@ sse_md5_build <- function(request) {
# encryption key. This handler does both if the MD5 has not been set by
# the caller.
sse_md5 <- function(params) {
return(.sse_md5(params, 'SSECustomer'))
return(.sse_md5(params, "SSECustomer"))
}

# S3 server-side encryption requires the encryption key to be sent to the
# server base64 encoded, as well as a base64-encoded MD5 hash of the
# encryption key. This handler does both if the MD5 has not been set by
# the caller specifically if the parameter is for the copy-source sse-c key.
copy_source_sse_md5 <- function(params) {
return(.sse_md5(params, 'CopySourceSSECustomer'))
return(.sse_md5(params, "CopySourceSSECustomer"))
}

.sse_md5 <- function(params, sse_member_prefix='SSECustomer') {
if (!.needs_s3_sse_customization(params, sse_member_prefix))
.sse_md5 <- function(params, sse_member_prefix = "SSECustomer") {
if (!.needs_s3_sse_customization(params, sse_member_prefix)) {
return(params)
sse_key_member <- paste0(sse_member_prefix, 'Key')
sse_md5_member <- paste0(sse_member_prefix, 'KeyMD5')
}
sse_key_member <- paste0(sse_member_prefix, "Key")
sse_md5_member <- paste0(sse_member_prefix, "KeyMD5")
key_md5_str <- base64enc::base64encode(
digest::digest(params[[sse_key_member]], serialize = FALSE, raw = TRUE)
)
Expand All @@ -186,9 +187,9 @@ copy_source_sse_md5 <- function(params) {
}

.needs_s3_sse_customization <- function(params, sse_member_prefix) {
return (
!is_empty(params[[paste0(sse_member_prefix, 'Key')]]) &
is_empty(params[[paste0(sse_member_prefix, 'KeyMD5')]])
return(
!is_empty(params[[paste0(sse_member_prefix, "Key")]]) &
is_empty(params[[paste0(sse_member_prefix, "KeyMD5")]])
)
}

Expand Down

0 comments on commit 496faaa

Please sign in to comment.