Many WebCrypto algorithms have nested algorithms, like hash in HMAC. We need to expose that as CryptoKey.algorithm.
Created attachment 215415 [details] proposed patch
Comment on attachment 215415 [details] proposed patch View in context: https://bugs.webkit.org/attachment.cgi?id=215415&action=review > Source/WebCore/bindings/js/JSCryptoAlgorithmBuilder.cpp:49 > + return std::unique_ptr<CryptoAlgorithmDescriptionBuilder>(new JSCryptoAlgorithmBuilder(m_exec)); We should use make_unique here. > Source/WebCore/bindings/js/JSCryptoAlgorithmBuilder.cpp:70 > + const JSCryptoAlgorithmBuilder* jsBuilder = static_cast<const JSCryptoAlgorithmBuilder*>(nestedBuilder); What guarantees this is a good cast? > Source/WebCore/bindings/js/JSCryptoAlgorithmBuilder.h:51 > + virtual void add(const char*, const CryptoAlgorithmDescriptionBuilder*) OVERRIDE; Why is this a pointer, not a reference?
> What guarantees this is a good cast? Not much. The code that clones a builder and code that adds it back will be all in one function, so it's very unlikely that a foreign builder will be passed to add(). And if a mistake like that was made, the code would just crash, so it would be discovered even by most cursory testing. Is there a better pattern for this kind of thing? Here is how a call site looks like: void CryptoKeyHMAC::buildAlgorithmDescription(CryptoAlgorithmDescriptionBuilder& builder) const { CryptoKey::buildAlgorithmDescription(builder); std::unique_ptr<CryptoAlgorithmDescriptionBuilder> hashDescriptionBuilder(builder.createEmptyClone()); hashDescriptionBuilder->add("name", CryptoAlgorithmRegistry::shared().nameForIdentifier(m_hash)); builder.add("hash", hashDescriptionBuilder.get()); // will add a star when add() takes a reference as you suggested builder.add("length", m_key.size()); }
Committed <http://trac.webkit.org/r158361>.