You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Maximum number of bytes that are allowed to be encrypted
under a single cached data key across messages.
The maximum value defined in the AWS Encryption SDK specification is 2 ** 63 - 1.
However Javascript can only perform safe operations on values
up to Number.MAX_SAFE_INTEGER === 9007199254740991 === 2 ** 53 - 1.
e.g
Number.MAX_SAFE_INTEGER + 1 === Number.MAX_SAFE_INTEGER + 2 => true
Number.MAX_SAFE_INTEGER + 1 > Number.MAX_SAFE_INTEGER + 2 => false
Number.MAX_SAFE_INTEGER + 1 < Number.MAX_SAFE_INTEGER + 2 => false
This means that after 2 ** 53 - 1 the process of accumulating a byte count
will never yield an accurate comparison and so, never halt.
The choice here to use 2 ** 53 - 1 instead of Number.MAX_SAFE_INTEGER is deliberate.
This is because in the future Number.MAX_SAFE_INTEGER could be raised to 2 ** 66
or some value larger 2 ** 63.
Copy file name to clipboardExpand all lines: modules/cache-material/src/caching_cryptographic_materials_decorators.ts
+4-4Lines changed: 4 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -49,17 +49,17 @@ export function decorateProperties<S extends SupportedAlgorithmSuites> (
49
49
/* Precondition: You *can not* cache something forever. */
50
50
needs(maxAge>0,'You must configure a maxAge')
51
51
/* Precondition: maxBytesEncrypted must be inside bounds. i.e. positive and not more than the maximum. */
52
-
needs(!maxBytesEncrypted||(maxBytesEncrypted>0&&Maximum.BYTES_PER_KEY>=maxBytesEncrypted),'maxBytesEncrypted is outside of bounds.')
52
+
needs(!maxBytesEncrypted||(maxBytesEncrypted>0&&Maximum.BYTES_PER_CACHED_KEY_LIMIT>=maxBytesEncrypted),'maxBytesEncrypted is outside of bounds.')
53
53
/* Precondition: maxMessagesEncrypted must be inside bounds. i.e. positive and not more than the maximum. */
54
-
needs(!maxMessagesEncrypted||(maxMessagesEncrypted>0&&Maximum.MESSAGES_PER_KEY>=maxMessagesEncrypted),'maxMessagesEncrypted is outside of bounds.')
54
+
needs(!maxMessagesEncrypted||(maxMessagesEncrypted>0&&Maximum.MESSAGES_PER_CACHED_KEY_LIMIT>=maxMessagesEncrypted),'maxMessagesEncrypted is outside of bounds.')
55
55
/* Precondition: partition must be a string. */
56
56
needs(partition&&typeofpartition==='string','partition must be a string.')
0 commit comments