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

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: ...and generateCertificateExpires signature Created 4 years, 9 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 611 matching lines...) Expand 10 before | Expand all | Expand 10 after
622 AlgorithmError error; 622 AlgorithmError error;
623 if (!normalizeAlgorithm(keygenAlgorithm, WebCryptoOperationGenerateKey, cryp toAlgorithm, &error)) { 623 if (!normalizeAlgorithm(keygenAlgorithm, WebCryptoOperationGenerateKey, cryp toAlgorithm, &error)) {
624 // Reject generateCertificate with the same error as was produced by Web Crypto. 624 // Reject generateCertificate with the same error as was produced by Web Crypto.
625 // |result| is garbage collected, no need to delete. 625 // |result| is garbage collected, no need to delete.
626 CryptoResultImpl* result = CryptoResultImpl::create(scriptState); 626 CryptoResultImpl* result = CryptoResultImpl::create(scriptState);
627 ScriptPromise promise = result->promise(); 627 ScriptPromise promise = result->promise();
628 result->completeWithError(error.errorType, error.errorDetails); 628 result->completeWithError(error.errorType, error.errorDetails);
629 return promise; 629 return promise;
630 } 630 }
631 631
632 // Check if |keygenAlgorithm| contains the optional DOMTimeStamp |expires| a ttribute.
633 Nullable<DOMTimeStamp> expires;
634 if (keygenAlgorithm.isDictionary()) {
635 Dictionary keygenAlgorithmDict = keygenAlgorithm.getAsDictionary();
636 if (keygenAlgorithmDict.hasProperty("expires")) {
637 v8::Local<v8::Value> expiresValue;
638 keygenAlgorithmDict.get("expires", expiresValue);
639 if (expiresValue->IsNumber()) {
640 double expiresDouble = expiresValue->ToNumber(scriptState->isola te()->GetCurrentContext()).ToLocalChecked()->Value();
641 if (expiresDouble >= 0) {
642 expires.set(static_cast<DOMTimeStamp>(expiresDouble));
643 }
644 }
645 }
646 }
647
632 // Convert from WebCrypto representation to recognized WebRTCKeyParams. WebR TC supports a small subset of what are valid AlgorithmIdentifiers. 648 // Convert from WebCrypto representation to recognized WebRTCKeyParams. WebR TC supports a small subset of what are valid AlgorithmIdentifiers.
633 const char* unsupportedParamsString = "The 1st argument provided is an Algor ithmIdentifier with a supported algorithm name, but the parameters are not suppo rted."; 649 const char* unsupportedParamsString = "The 1st argument provided is an Algor ithmIdentifier with a supported algorithm name, but the parameters are not suppo rted.";
634 Nullable<WebRTCKeyParams> keyParams; 650 Nullable<WebRTCKeyParams> keyParams;
635 switch (cryptoAlgorithm.id()) { 651 switch (cryptoAlgorithm.id()) {
636 case WebCryptoAlgorithmIdRsaSsaPkcs1v1_5: 652 case WebCryptoAlgorithmIdRsaSsaPkcs1v1_5:
637 // name: "RSASSA-PKCS1-v1_5" 653 // name: "RSASSA-PKCS1-v1_5"
638 unsigned publicExponent; 654 unsigned publicExponent;
639 // "publicExponent" must fit in an unsigned int. The only recognized "ha sh" is "SHA-256". 655 // "publicExponent" must fit in an unsigned int. The only recognized "ha sh" is "SHA-256".
640 if (cryptoAlgorithm.rsaHashedKeyGenParams()->convertPublicExponentToUnsi gned(publicExponent) 656 if (cryptoAlgorithm.rsaHashedKeyGenParams()->convertPublicExponentToUnsi gned(publicExponent)
641 && cryptoAlgorithm.rsaHashedKeyGenParams()->hash().id() == WebCrypto AlgorithmIdSha256) { 657 && cryptoAlgorithm.rsaHashedKeyGenParams()->hash().id() == WebCrypto AlgorithmIdSha256) {
(...skipping 26 matching lines...) Expand all
668 return ScriptPromise::rejectWithDOMException(scriptState, DOMException:: create(NotSupportedError, unsupportedParamsString)); 684 return ScriptPromise::rejectWithDOMException(scriptState, DOMException:: create(NotSupportedError, unsupportedParamsString));
669 } 685 }
670 686
671 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState) ; 687 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState) ;
672 ScriptPromise promise = resolver->promise(); 688 ScriptPromise promise = resolver->promise();
673 689
674 WebRTCCertificateObserver* certificateObserver = WebRTCCertificateObserver:: create(resolver); 690 WebRTCCertificateObserver* certificateObserver = WebRTCCertificateObserver:: create(resolver);
675 691
676 // Generate certificate. The |certificateObserver| will resolve the promise asynchronously upon completion. 692 // Generate certificate. The |certificateObserver| will resolve the promise asynchronously upon completion.
677 // The observer will manage its own destruction as well as the resolver's de struction. 693 // The observer will manage its own destruction as well as the resolver's de struction.
678 certificateGenerator->generateCertificate( 694 if (expires.isNull()) {
679 keyParams.get(), 695 certificateGenerator->generateCertificate(
680 toDocument(scriptState->executionContext())->url(), 696 keyParams.get(),
681 toDocument(scriptState->executionContext())->firstPartyForCookies(), 697 toDocument(scriptState->executionContext())->url(),
682 certificateObserver); 698 toDocument(scriptState->executionContext())->firstPartyForCookies(),
699 certificateObserver);
700 } else {
701 certificateGenerator->generateCertificate(
702 keyParams.get(),
703 toDocument(scriptState->executionContext())->url(),
704 toDocument(scriptState->executionContext())->firstPartyForCookies(),
705 expires.get(),
706 certificateObserver);
707 }
683 708
684 return promise; 709 return promise;
685 } 710 }
686 711
687 ScriptPromise RTCPeerConnection::addIceCandidate(ScriptState* scriptState, const RTCIceCandidateInitOrRTCIceCandidate& candidate) 712 ScriptPromise RTCPeerConnection::addIceCandidate(ScriptState* scriptState, const RTCIceCandidateInitOrRTCIceCandidate& candidate)
688 { 713 {
689 if (m_signalingState == SignalingStateClosed) 714 if (m_signalingState == SignalingStateClosed)
690 return ScriptPromise::rejectWithDOMException(scriptState, DOMException:: create(InvalidStateError, kSignalingStateClosedMessage)); 715 return ScriptPromise::rejectWithDOMException(scriptState, DOMException:: create(InvalidStateError, kSignalingStateClosedMessage));
691 716
692 if (isIceCandidateMissingSdp(candidate)) 717 if (isIceCandidateMissingSdp(candidate))
(...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after
1132 { 1157 {
1133 visitor->trace(m_localStreams); 1158 visitor->trace(m_localStreams);
1134 visitor->trace(m_remoteStreams); 1159 visitor->trace(m_remoteStreams);
1135 visitor->trace(m_dispatchScheduledEventRunner); 1160 visitor->trace(m_dispatchScheduledEventRunner);
1136 visitor->trace(m_scheduledEvents); 1161 visitor->trace(m_scheduledEvents);
1137 RefCountedGarbageCollectedEventTargetWithInlineData<RTCPeerConnection>::trac e(visitor); 1162 RefCountedGarbageCollectedEventTargetWithInlineData<RTCPeerConnection>::trac e(visitor);
1138 ActiveDOMObject::trace(visitor); 1163 ActiveDOMObject::trace(visitor);
1139 } 1164 }
1140 1165
1141 } // namespace blink 1166 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698