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

Side by Side Diff: third_party/WebKit/Source/modules/mediastream/RTCPeerConnection.cpp

Issue 1740993002: RTCPeerConnection.generateCertificate: Optionally specify expiration. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed comments Created 4 years, 8 months 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 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 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 654 matching lines...) Expand 10 before | Expand all | Expand 10 after
665 AlgorithmError error; 665 AlgorithmError error;
666 if (!normalizeAlgorithm(keygenAlgorithm, WebCryptoOperationGenerateKey, cryp toAlgorithm, &error)) { 666 if (!normalizeAlgorithm(keygenAlgorithm, WebCryptoOperationGenerateKey, cryp toAlgorithm, &error)) {
667 // Reject generateCertificate with the same error as was produced by Web Crypto. 667 // Reject generateCertificate with the same error as was produced by Web Crypto.
668 // |result| is garbage collected, no need to delete. 668 // |result| is garbage collected, no need to delete.
669 CryptoResultImpl* result = CryptoResultImpl::create(scriptState); 669 CryptoResultImpl* result = CryptoResultImpl::create(scriptState);
670 ScriptPromise promise = result->promise(); 670 ScriptPromise promise = result->promise();
671 result->completeWithError(error.errorType, error.errorDetails); 671 result->completeWithError(error.errorType, error.errorDetails);
672 return promise; 672 return promise;
673 } 673 }
674 674
675 // Check if |keygenAlgorithm| contains the optional DOMTimeStamp |expires| a ttribute.
676 Nullable<DOMTimeStamp> expires;
677 if (keygenAlgorithm.isDictionary()) {
678 Dictionary keygenAlgorithmDict = keygenAlgorithm.getAsDictionary();
679 if (keygenAlgorithmDict.hasProperty("expires")) {
680 v8::Local<v8::Value> expiresValue;
681 keygenAlgorithmDict.get("expires", expiresValue);
682 if (expiresValue->IsNumber()) {
683 double expiresDouble = expiresValue->ToNumber(scriptState->isola te()->GetCurrentContext()).ToLocalChecked()->Value();
684 if (expiresDouble >= 0) {
685 expires.set(static_cast<DOMTimeStamp>(expiresDouble));
686 }
687 }
688 }
689 }
690
675 // Convert from WebCrypto representation to recognized WebRTCKeyParams. WebR TC supports a small subset of what are valid AlgorithmIdentifiers. 691 // Convert from WebCrypto representation to recognized WebRTCKeyParams. WebR TC supports a small subset of what are valid AlgorithmIdentifiers.
676 const char* unsupportedParamsString = "The 1st argument provided is an Algor ithmIdentifier with a supported algorithm name, but the parameters are not suppo rted."; 692 const char* unsupportedParamsString = "The 1st argument provided is an Algor ithmIdentifier with a supported algorithm name, but the parameters are not suppo rted.";
677 Nullable<WebRTCKeyParams> keyParams; 693 Nullable<WebRTCKeyParams> keyParams;
678 switch (cryptoAlgorithm.id()) { 694 switch (cryptoAlgorithm.id()) {
679 case WebCryptoAlgorithmIdRsaSsaPkcs1v1_5: 695 case WebCryptoAlgorithmIdRsaSsaPkcs1v1_5:
680 // name: "RSASSA-PKCS1-v1_5" 696 // name: "RSASSA-PKCS1-v1_5"
681 unsigned publicExponent; 697 unsigned publicExponent;
682 // "publicExponent" must fit in an unsigned int. The only recognized "ha sh" is "SHA-256". 698 // "publicExponent" must fit in an unsigned int. The only recognized "ha sh" is "SHA-256".
683 if (cryptoAlgorithm.rsaHashedKeyGenParams()->convertPublicExponentToUnsi gned(publicExponent) 699 if (cryptoAlgorithm.rsaHashedKeyGenParams()->convertPublicExponentToUnsi gned(publicExponent)
684 && cryptoAlgorithm.rsaHashedKeyGenParams()->hash().id() == WebCrypto AlgorithmIdSha256) { 700 && cryptoAlgorithm.rsaHashedKeyGenParams()->hash().id() == WebCrypto AlgorithmIdSha256) {
(...skipping 26 matching lines...) Expand all
711 return ScriptPromise::rejectWithDOMException(scriptState, DOMException:: create(NotSupportedError, unsupportedParamsString)); 727 return ScriptPromise::rejectWithDOMException(scriptState, DOMException:: create(NotSupportedError, unsupportedParamsString));
712 } 728 }
713 729
714 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState) ; 730 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState) ;
715 ScriptPromise promise = resolver->promise(); 731 ScriptPromise promise = resolver->promise();
716 732
717 std::unique_ptr<WebRTCCertificateObserver> certificateObserver(WebRTCCertifi cateObserver::create(resolver)); 733 std::unique_ptr<WebRTCCertificateObserver> certificateObserver(WebRTCCertifi cateObserver::create(resolver));
718 734
719 // Generate certificate. The |certificateObserver| will resolve the promise asynchronously upon completion. 735 // Generate certificate. The |certificateObserver| will resolve the promise asynchronously upon completion.
720 // The observer will manage its own destruction as well as the resolver's de struction. 736 // The observer will manage its own destruction as well as the resolver's de struction.
721 certificateGenerator->generateCertificate( 737 if (expires.isNull()) {
722 keyParams.get(), 738 certificateGenerator->generateCertificate(
723 toDocument(scriptState->getExecutionContext())->url(), 739 keyParams.get(),
724 toDocument(scriptState->getExecutionContext())->firstPartyForCookies(), 740 toDocument(scriptState->getExecutionContext())->url(),
725 std::move(certificateObserver)); 741 toDocument(scriptState->getExecutionContext())->firstPartyForCookies (),
742 std::move(certificateObserver));
743 } else {
744 certificateGenerator->generateCertificateWithExpiration(
745 keyParams.get(),
746 toDocument(scriptState->getExecutionContext())->url(),
747 toDocument(scriptState->getExecutionContext())->firstPartyForCookies (),
748 expires.get(),
749 std::move(certificateObserver));
750 }
726 751
727 return promise; 752 return promise;
728 } 753 }
729 754
730 ScriptPromise RTCPeerConnection::addIceCandidate(ScriptState* scriptState, const RTCIceCandidateInitOrRTCIceCandidate& candidate) 755 ScriptPromise RTCPeerConnection::addIceCandidate(ScriptState* scriptState, const RTCIceCandidateInitOrRTCIceCandidate& candidate)
731 { 756 {
732 if (m_signalingState == SignalingStateClosed) 757 if (m_signalingState == SignalingStateClosed)
733 return ScriptPromise::rejectWithDOMException(scriptState, DOMException:: create(InvalidStateError, kSignalingStateClosedMessage)); 758 return ScriptPromise::rejectWithDOMException(scriptState, DOMException:: create(InvalidStateError, kSignalingStateClosedMessage));
734 759
735 if (isIceCandidateMissingSdp(candidate)) 760 if (isIceCandidateMissingSdp(candidate))
(...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after
1175 { 1200 {
1176 visitor->trace(m_localStreams); 1201 visitor->trace(m_localStreams);
1177 visitor->trace(m_remoteStreams); 1202 visitor->trace(m_remoteStreams);
1178 visitor->trace(m_dispatchScheduledEventRunner); 1203 visitor->trace(m_dispatchScheduledEventRunner);
1179 visitor->trace(m_scheduledEvents); 1204 visitor->trace(m_scheduledEvents);
1180 EventTargetWithInlineData::trace(visitor); 1205 EventTargetWithInlineData::trace(visitor);
1181 ActiveDOMObject::trace(visitor); 1206 ActiveDOMObject::trace(visitor);
1182 } 1207 }
1183 1208
1184 } // namespace blink 1209 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698