public byte[] ReverseTransform(byte[] pkt, int offset, int length) { // wrap data into raw packet for readable format this.packet.Wrap(pkt, offset, length); // Associate the packet with its encryption context long ssrc = this.packet.GetRTCPSSRC(); SrtcpCryptoContext context = null; contexts.TryGetValue(ssrc, out context); if (context == null) { context = reverseEngine.GetDefaultContextControl().DeriveContext(ssrc); context.DeriveSrtcpKeys(); contexts[ssrc] = context; } // Decode packet to RTCP format bool reversed = context.ReverseTransformPacket(packet); if (reversed) { return(packet.GetData()); } return(null); }
/** * Derive a new SRTPCryptoContext for use with a new SSRC * * This method returns a new SRTPCryptoContext initialized with the data of * this SRTPCryptoContext. Replacing the SSRC, Roll-over-Counter, and the * key derivation rate the application cab use this SRTPCryptoContext to * encrypt / decrypt a new stream (Synchronization source) inside one RTP * session. * * Before the application can use this SRTPCryptoContext it must call the * deriveSrtpKeys method. * * @param ssrc * The SSRC for this context * @return a new SRTPCryptoContext with all relevant data set. */ public SrtcpCryptoContext DeriveContext(long ssrc) { SrtcpCryptoContext pcc = null; pcc = new SrtcpCryptoContext(ssrc, masterKey, masterSalt, policy); return(pcc); }
public byte[] ReverseTransform(byte[] pkt, int offset, int length) { var isLocked = Interlocked.CompareExchange(ref _isLocked, 1, 0) != 0; try { // wrap data into raw packet for readable format var packet = !isLocked ? this.packet : new RawPacket(); packet.Wrap(pkt, offset, length); // Associate the packet with its encryption context long ssrc = packet.GetRTCPSSRC(); SrtcpCryptoContext context = null; contexts.TryGetValue(ssrc, out context); if (context == null) { context = reverseEngine.GetDefaultContextControl().DeriveContext(ssrc); context.DeriveSrtcpKeys(); contexts.AddOrUpdate(ssrc, context, (a, b) => context); } // Decode packet to RTCP format byte[] result = null; bool reversed = context.ReverseTransformPacket(packet); if (reversed) { result = packet.GetData(); } return(result); } finally { //Unlock if (!isLocked) { Interlocked.CompareExchange(ref _isLocked, 0, 1); } } }
public byte[] Transform(byte[] pkt, int offset, int length) { // Wrap the data into raw packet for readable format this.packet.Wrap(pkt, offset, length); // Associate the packet with its encryption context long ssrc = this.packet.GetRTCPSSRC(); SrtcpCryptoContext context = null; contexts.TryGetValue(ssrc, out context); if (context == null) { context = forwardEngine.GetDefaultContextControl().DeriveContext(ssrc); context.DeriveSrtcpKeys(); contexts.AddOrUpdate(ssrc, context, (a, b) => context); } // Secure packet into SRTCP format context.TransformPacket(packet); return(packet.GetData()); }