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

Side by Side Diff: Source/modules/crypto/NormalizeAlgorithm.cpp

Issue 779723002: WebCrypto: Add parsing for the algorithm parameter AesDerivedKey. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: add override 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | Source/platform/exported/WebCryptoAlgorithm.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 742 matching lines...) Expand 10 before | Expand all | Expand 10 after
753 CryptoKey* cryptoKey = V8CryptoKey::toImplWithTypeCheck(raw.isolate(), v8Val ue); 753 CryptoKey* cryptoKey = V8CryptoKey::toImplWithTypeCheck(raw.isolate(), v8Val ue);
754 if (!cryptoKey) { 754 if (!cryptoKey) {
755 setSyntaxError(context.toString("public", "Must be a CryptoKey"), error) ; 755 setSyntaxError(context.toString("public", "Must be a CryptoKey"), error) ;
756 return false; 756 return false;
757 } 757 }
758 758
759 params = adoptPtr(new WebCryptoEcdhKeyDeriveParams(cryptoKey->key())); 759 params = adoptPtr(new WebCryptoEcdhKeyDeriveParams(cryptoKey->key()));
760 return true; 760 return true;
761 } 761 }
762 762
763 // Defined by the WebCrypto spec as:
764 //
765 // dictionary AesDerivedKeyParams : Algorithm {
766 // [EnforceRange] required unsigned short length;
767 // };
768 bool parseAesDerivedKeyParams(const Dictionary& raw, OwnPtr<WebCryptoAlgorithmPa rams>& params, const ErrorContext& context, AlgorithmError* error)
769 {
770 uint16_t length;
771 if (!getUint16(raw, "length", length, context, error))
772 return false;
773
774 params = adoptPtr(new WebCryptoAesDerivedKeyParams(length));
775 return true;
776 }
777
763 bool parseAlgorithmParams(const Dictionary& raw, WebCryptoAlgorithmParamsType ty pe, OwnPtr<WebCryptoAlgorithmParams>& params, ErrorContext& context, AlgorithmEr ror* error) 778 bool parseAlgorithmParams(const Dictionary& raw, WebCryptoAlgorithmParamsType ty pe, OwnPtr<WebCryptoAlgorithmParams>& params, ErrorContext& context, AlgorithmEr ror* error)
764 { 779 {
765 switch (type) { 780 switch (type) {
766 case WebCryptoAlgorithmParamsTypeNone: 781 case WebCryptoAlgorithmParamsTypeNone:
767 return true; 782 return true;
768 case WebCryptoAlgorithmParamsTypeAesCbcParams: 783 case WebCryptoAlgorithmParamsTypeAesCbcParams:
769 context.add("AesCbcParams"); 784 context.add("AesCbcParams");
770 return parseAesCbcParams(raw, params, context, error); 785 return parseAesCbcParams(raw, params, context, error);
771 case WebCryptoAlgorithmParamsTypeAesKeyGenParams: 786 case WebCryptoAlgorithmParamsTypeAesKeyGenParams:
772 context.add("AesKeyGenParams"); 787 context.add("AesKeyGenParams");
(...skipping 27 matching lines...) Expand all
800 return parseEcdsaParams(raw, params, context, error); 815 return parseEcdsaParams(raw, params, context, error);
801 case WebCryptoAlgorithmParamsTypeEcKeyGenParams: 816 case WebCryptoAlgorithmParamsTypeEcKeyGenParams:
802 context.add("EcKeyGenParams"); 817 context.add("EcKeyGenParams");
803 return parseEcKeyGenParams(raw, params, context, error); 818 return parseEcKeyGenParams(raw, params, context, error);
804 case WebCryptoAlgorithmParamsTypeEcKeyImportParams: 819 case WebCryptoAlgorithmParamsTypeEcKeyImportParams:
805 context.add("EcKeyImportParams"); 820 context.add("EcKeyImportParams");
806 return parseEcKeyImportParams(raw, params, context, error); 821 return parseEcKeyImportParams(raw, params, context, error);
807 case WebCryptoAlgorithmParamsTypeEcdhKeyDeriveParams: 822 case WebCryptoAlgorithmParamsTypeEcdhKeyDeriveParams:
808 context.add("EcdhKeyDeriveParams"); 823 context.add("EcdhKeyDeriveParams");
809 return parseEcdhKeyDeriveParams(raw, params, context, error); 824 return parseEcdhKeyDeriveParams(raw, params, context, error);
825 case WebCryptoAlgorithmParamsTypeAesDerivedKeyParams:
826 context.add("AesDerivedKeyParams");
827 return parseAesDerivedKeyParams(raw, params, context, error);
810 } 828 }
811 ASSERT_NOT_REACHED(); 829 ASSERT_NOT_REACHED();
812 return false; 830 return false;
813 } 831 }
814 832
815 const char* operationToString(WebCryptoOperation op) 833 const char* operationToString(WebCryptoOperation op)
816 { 834 {
817 switch (op) { 835 switch (op) {
818 case WebCryptoOperationEncrypt: 836 case WebCryptoOperationEncrypt:
819 return "encrypt"; 837 return "encrypt";
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
897 } 915 }
898 916
899 } // namespace 917 } // namespace
900 918
901 bool normalizeAlgorithm(const AlgorithmIdentifier& raw, WebCryptoOperation op, W ebCryptoAlgorithm& algorithm, AlgorithmError* error) 919 bool normalizeAlgorithm(const AlgorithmIdentifier& raw, WebCryptoOperation op, W ebCryptoAlgorithm& algorithm, AlgorithmError* error)
902 { 920 {
903 return parseAlgorithmIdentifier(raw, op, algorithm, ErrorContext(), error); 921 return parseAlgorithmIdentifier(raw, op, algorithm, ErrorContext(), error);
904 } 922 }
905 923
906 } // namespace blink 924 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | Source/platform/exported/WebCryptoAlgorithm.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698