Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1695)

Unified Diff: Source/modules/crypto/NormalizeAlgorithm.cpp

Issue 790373002: Address a FIXME. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/modules/crypto/NormalizeAlgorithm.cpp
diff --git a/Source/modules/crypto/NormalizeAlgorithm.cpp b/Source/modules/crypto/NormalizeAlgorithm.cpp
index 485b6f23f59ed84d391cf8590731ea18c88dcb91..2d9f935c6ff878f4b8535942f556c5264c71e36c 100644
--- a/Source/modules/crypto/NormalizeAlgorithm.cpp
+++ b/Source/modules/crypto/NormalizeAlgorithm.cpp
@@ -408,6 +408,16 @@ bool getOptionalUint32(const Dictionary& raw, const char* propertyName, bool& ha
return true;
}
+bool getOptionalUint8(const Dictionary& raw, const char* propertyName, bool& hasValue, uint8_t& value, const ErrorContext& context, AlgorithmError* error)
+{
+ double number;
+ if (!getOptionalInteger(raw, propertyName, hasValue, number, 0, 0xFF, context, error))
+ return false;
+ if (hasValue)
+ value = number;
+ return true;
+}
+
bool getAlgorithmIdentifier(const Dictionary& raw, const char* propertyName, AlgorithmIdentifier& value, const ErrorContext& context, AlgorithmError* error)
{
// FIXME: This is not correct: http://crbug.com/438060
@@ -590,7 +600,7 @@ bool parseAesCtrParams(const Dictionary& raw, OwnPtr<WebCryptoAlgorithmParams>&
// dictionary AesGcmParams : Algorithm {
// required BufferSource iv;
// BufferSource additionalData;
-// [EnforceRange] octet tagLength; // May be 0-128
+// [EnforceRange] octet tagLength;
// }
bool parseAesGcmParams(const Dictionary& raw, OwnPtr<WebCryptoAlgorithmParams>& params, const ErrorContext& context, AlgorithmError* error)
{
@@ -603,10 +613,9 @@ bool parseAesGcmParams(const Dictionary& raw, OwnPtr<WebCryptoAlgorithmParams>&
if (!getOptionalBufferSource(raw, "additionalData", hasAdditionalData, additionalDataBufferSource, context, error))
return false;
- double tagLength;
+ uint8_t tagLength;
bool hasTagLength;
- // FIXME: Layering -- should only enforce the WebIDL's "octet" range here, not the AES-CTR tagLength.
- if (!getOptionalInteger(raw, "tagLength", hasTagLength, tagLength, 0, 128, context, error))
+ if (!getOptionalUint8(raw, "tagLength", hasTagLength, tagLength, context, error))
return false;
DOMArrayPiece iv(ivBufferSource);

Powered by Google App Engine
This is Rietveld 408576698