OLD | NEW |
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 589 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
600 if (!getOptionalCryptoOperationData(raw, "label", hasLabel, label, context,
error)) | 600 if (!getOptionalCryptoOperationData(raw, "label", hasLabel, label, context,
error)) |
601 return false; | 601 return false; |
602 | 602 |
603 const unsigned char* labelStart = hasLabel ? static_cast<const unsigned char
*>(label->baseAddress()) : 0; | 603 const unsigned char* labelStart = hasLabel ? static_cast<const unsigned char
*>(label->baseAddress()) : 0; |
604 unsigned labelLength = hasLabel ? label->byteLength() : 0; | 604 unsigned labelLength = hasLabel ? label->byteLength() : 0; |
605 | 605 |
606 params = adoptPtr(new WebCryptoRsaOaepParams(hasLabel, labelStart, labelLeng
th)); | 606 params = adoptPtr(new WebCryptoRsaOaepParams(hasLabel, labelStart, labelLeng
th)); |
607 return true; | 607 return true; |
608 } | 608 } |
609 | 609 |
| 610 // Defined by the WebCrypto spec as: |
| 611 // |
| 612 // dictionary RsaPssParams : Algorithm { |
| 613 // [EnforceRange] required unsigned long saltLength; |
| 614 // }; |
| 615 bool parseRsaPssParams(const Dictionary& raw, OwnPtr<WebCryptoAlgorithmParams>&
params, const ErrorContext& context, AlgorithmError* error) |
| 616 { |
| 617 uint32_t saltLengthBytes; |
| 618 if (!getUint32(raw, "saltLength", saltLengthBytes, context, error)) |
| 619 return false; |
| 620 |
| 621 params = adoptPtr(new WebCryptoRsaPssParams(saltLengthBytes)); |
| 622 return true; |
| 623 } |
| 624 |
610 bool parseAlgorithmParams(const Dictionary& raw, WebCryptoAlgorithmParamsType ty
pe, OwnPtr<WebCryptoAlgorithmParams>& params, ErrorContext& context, AlgorithmEr
ror* error) | 625 bool parseAlgorithmParams(const Dictionary& raw, WebCryptoAlgorithmParamsType ty
pe, OwnPtr<WebCryptoAlgorithmParams>& params, ErrorContext& context, AlgorithmEr
ror* error) |
611 { | 626 { |
612 switch (type) { | 627 switch (type) { |
613 case WebCryptoAlgorithmParamsTypeNone: | 628 case WebCryptoAlgorithmParamsTypeNone: |
614 return true; | 629 return true; |
615 case WebCryptoAlgorithmParamsTypeAesCbcParams: | 630 case WebCryptoAlgorithmParamsTypeAesCbcParams: |
616 context.add("AesCbcParams"); | 631 context.add("AesCbcParams"); |
617 return parseAesCbcParams(raw, params, context, error); | 632 return parseAesCbcParams(raw, params, context, error); |
618 case WebCryptoAlgorithmParamsTypeAesKeyGenParams: | 633 case WebCryptoAlgorithmParamsTypeAesKeyGenParams: |
619 context.add("AesKeyGenParams"); | 634 context.add("AesKeyGenParams"); |
(...skipping 13 matching lines...) Expand all Loading... |
633 case WebCryptoAlgorithmParamsTypeAesCtrParams: | 648 case WebCryptoAlgorithmParamsTypeAesCtrParams: |
634 context.add("AesCtrParams"); | 649 context.add("AesCtrParams"); |
635 return parseAesCtrParams(raw, params, context, error); | 650 return parseAesCtrParams(raw, params, context, error); |
636 case WebCryptoAlgorithmParamsTypeAesGcmParams: | 651 case WebCryptoAlgorithmParamsTypeAesGcmParams: |
637 context.add("AesGcmParams"); | 652 context.add("AesGcmParams"); |
638 return parseAesGcmParams(raw, params, context, error); | 653 return parseAesGcmParams(raw, params, context, error); |
639 case WebCryptoAlgorithmParamsTypeRsaOaepParams: | 654 case WebCryptoAlgorithmParamsTypeRsaOaepParams: |
640 context.add("RsaOaepParams"); | 655 context.add("RsaOaepParams"); |
641 return parseRsaOaepParams(raw, params, context, error); | 656 return parseRsaOaepParams(raw, params, context, error); |
642 break; | 657 break; |
| 658 case WebCryptoAlgorithmParamsTypeRsaPssParams: |
| 659 context.add("RsaPssParams"); |
| 660 return parseRsaPssParams(raw, params, context, error); |
| 661 break; |
643 } | 662 } |
644 ASSERT_NOT_REACHED(); | 663 ASSERT_NOT_REACHED(); |
645 return false; | 664 return false; |
646 } | 665 } |
647 | 666 |
648 const char* operationToString(WebCryptoOperation op) | 667 const char* operationToString(WebCryptoOperation op) |
649 { | 668 { |
650 switch (op) { | 669 switch (op) { |
651 case WebCryptoOperationEncrypt: | 670 case WebCryptoOperationEncrypt: |
652 return "encrypt"; | 671 return "encrypt"; |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
719 } | 738 } |
720 | 739 |
721 } // namespace | 740 } // namespace |
722 | 741 |
723 bool normalizeAlgorithm(const Dictionary& raw, WebCryptoOperation op, WebCryptoA
lgorithm& algorithm, AlgorithmError* error) | 742 bool normalizeAlgorithm(const Dictionary& raw, WebCryptoOperation op, WebCryptoA
lgorithm& algorithm, AlgorithmError* error) |
724 { | 743 { |
725 return parseAlgorithm(raw, op, algorithm, ErrorContext(), error); | 744 return parseAlgorithm(raw, op, algorithm, ErrorContext(), error); |
726 } | 745 } |
727 | 746 |
728 } // namespace blink | 747 } // namespace blink |
OLD | NEW |