Bug 892148 - Make DTLS fingerprint accessible from JS r=abr
authorMax Jonas Werner <mail@makk.es>
Wed, 04 Dec 2013 15:36:00 -0600
changeset 158851 4dd987eef4313d4163da241b79e18000504f07b0
parent 158850 7b6a44800b27f588fdc296b1d4555f849e607491
child 158852 30d37e5c0b90d6ccce6c79aa31dc93be0eb4ad55
push id25763
push usercbook@mozilla.com
push dateThu, 05 Dec 2013 11:39:19 +0000
treeherdermozilla-central@056164bcce96 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersabr
bugs892148
milestone28.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 892148 - Make DTLS fingerprint accessible from JS r=abr
dom/webidl/PeerConnectionImpl.webidl
media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp
media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.h
--- a/dom/webidl/PeerConnectionImpl.webidl
+++ b/dom/webidl/PeerConnectionImpl.webidl
@@ -62,16 +62,17 @@ interface PeerConnectionImpl  {
    */
   [Throws]
   void addIceCandidate(DOMString candidate, DOMString mid, unsigned short level);
 
   /* Puts the SIPCC engine back to 'kIdle', shuts down threads, deletes state */
   void close();
 
   /* Attributes */
+  readonly attribute DOMString fingerprint;
   readonly attribute DOMString localDescription;
   readonly attribute DOMString remoteDescription;
 
   readonly attribute PCImplIceConnectionState iceConnectionState;
   readonly attribute PCImplIceGatheringState iceGatheringState;
   readonly attribute PCImplReadyState readyState;
   readonly attribute PCImplSignalingState signalingState;
   readonly attribute PCImplSipccState sipccState;
--- a/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp
+++ b/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp
@@ -782,28 +782,28 @@ PeerConnectionImpl::Initialize(PeerConne
     CSFLogError(logTag, "%s: Generate returned NULL", __FUNCTION__);
     return NS_ERROR_FAILURE;
   }
 
   // Set the fingerprint. Right now assume we only have one
   // DTLS identity
   unsigned char fingerprint[DTLS_FINGERPRINT_LENGTH];
   size_t fingerprint_length;
-  res = mIdentity->ComputeFingerprint("sha-1",
+  res = mIdentity->ComputeFingerprint("sha-256",
                                       fingerprint,
                                       sizeof(fingerprint),
                                       &fingerprint_length);
 
   if (NS_FAILED(res)) {
     CSFLogError(logTag, "%s: ComputeFingerprint failed: %u",
       __FUNCTION__, static_cast<uint32_t>(res));
     return res;
   }
 
-  mFingerprint = "sha-1 " + mIdentity->FormatFingerprint(fingerprint,
+  mFingerprint = "sha-256 " + mIdentity->FormatFingerprint(fingerprint,
                                                          fingerprint_length);
   if (NS_FAILED(res)) {
     CSFLogError(logTag, "%s: do_GetService failed: %u",
       __FUNCTION__, static_cast<uint32_t>(res));
     return res;
   }
 
   return NS_OK;
@@ -1335,16 +1335,17 @@ PeerConnectionImpl::SetRemoteFingerprint
     mRemoteFingerprint = std::string(fingerprint);
     CSFLogDebug(logTag, "Setting remote fingerprint to %s", mRemoteFingerprint.c_str());
     return NS_OK;
   } else {
     CSFLogError(logTag, "%s: Invalid Remote Finger Print", __FUNCTION__);
     return NS_ERROR_FAILURE;
   }
 }
+*/
 
 NS_IMETHODIMP
 PeerConnectionImpl::GetFingerprint(char** fingerprint)
 {
   MOZ_ASSERT(fingerprint);
 
   if (!mIdentity) {
     return NS_ERROR_FAILURE;
@@ -1352,17 +1353,16 @@ PeerConnectionImpl::GetFingerprint(char*
 
   char* tmp = new char[mFingerprint.size() + 1];
   std::copy(mFingerprint.begin(), mFingerprint.end(), tmp);
   tmp[mFingerprint.size()] = '\0';
 
   *fingerprint = tmp;
   return NS_OK;
 }
-*/
 
 NS_IMETHODIMP
 PeerConnectionImpl::GetLocalDescription(char** aSDP)
 {
   PC_AUTO_ENTER_API_CALL_NO_CHECK();
   MOZ_ASSERT(aSDP);
 
   char* tmp = new char[mLocalSDP.size() + 1];
--- a/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.h
+++ b/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.h
@@ -341,16 +341,25 @@ public:
   }
 
   NS_IMETHODIMP_TO_ERRORRESULT(RemoveStream, ErrorResult &rv,
                                DOMMediaStream& aMediaStream)
   {
     rv = RemoveStream(aMediaStream);
   }
 
+  NS_IMETHODIMP GetFingerprint(char** fingerprint);
+  void GetFingerprint(nsAString& fingerprint)
+  {
+    char *tmp;
+    GetFingerprint(&tmp);
+    fingerprint.AssignASCII(tmp);
+    delete[] tmp;
+  }
+
   NS_IMETHODIMP GetLocalDescription(char** aSDP);
 
   void GetLocalDescription(nsAString& aSDP)
   {
     char *tmp;
     GetLocalDescription(&tmp);
     aSDP.AssignASCII(tmp);
     delete tmp;