Node.JS TCP Server Encryption Layer - encryption

Does Node.JS support sending binary data? or does it require a Base64 layer?
Also, how best would I create an encryption layer? I am expecting I will create a module that acts exactly like the net module (as it pertains to tcp client/server communication) and then just call an underlying net module.
However, I would like the encryption layer to be easily added to a file I/O stream. Would those two operations have to work different?
I know little about Node.JS but I know Java and browser based JavaScript very well.

Yes, Node.js supports binary data.
For encrypted communication it has built-in support for SSL / TLS.

Related

Is it possible to send realtime data from arduino to a server api?

I know how to build server api with java. Is it possible to send real time data from the arduino to my server api to save real time data.
Yes it's certainly possible however your server API must also be taken into consideration for best practices.
Typically you would use a protocol called MQTT to achieve this. It enables you to transmit data from resource constrained devices to a server, however HTTP has also been used. It really depends on the kinds of performance & reliability needs of your system.
If you're using a popular cloud platform they offer managed IOT services that provide well defined API's to do this.

Manually encrypt data with OpenSSL with Qt

I know that Qt has SSL/TLS support to TCP communications, and I wanted to leverage the cross-platform high-level API to encrypt communications not based on TCP. If possibly keeping Diffie–Hellman protocol to establish the secured communication.
Now I've been looking at the classes sources, and where data is encrypted for instance, and it appears to be all private and not easily reusable.
Is there an easy way to use what was developed by Qt for something else than TCP, at least for simple encryption? full SSL support?
I guess you can always open a local TCP port, and build a TCP-to-Other local proxy, but that looks a bit silly, just to be able to reuse Qt implementation.
I found the Hacking on Qt SSL Support in the Wiki, which gives some perspective but not exactly how to leverage existing implementation.

Decrypt packet in lua dissector

I am working on a custom dissector for Wireshark in lua.
Certain PDUs in the protocol is encrypted using AES and I would like to decrypt these so that I can show the clear content in Wireshark. Is this possible with a lua dissector and what APIs can I use to make the decryption?
Or do I need to make a c/c++ dissector to make a dissector that decrypts data?
Personally i use lua-crypto but it requires OpenSSL.
You can check lua-wiki.
Recently i create wrapper for this AES implementation called bgcrypto.
It has no external dependencies but i really do not use it yet in real work.
At the moment Wireshark (2.0) does not expose a crypto API to LUA dissectors, so you have to implement it in the Lua dissector.
For a pure Lua solution you can use lua-lockbox (as mentioned on the Lua wiki). This is not recommended if you need performance, but might be useful for prototyping.
Faster AES decryption implementations typically use a native library, for example:
LuaCrypto - uses OpenSSL, though it does not seem maintained
lcrypt - uses libtomcrypt, but there seems to be no development either
Since none of these libraries satisfied my needs, I developed a new one based on Libgcrypt for these reasons:
Wireshark already links to Libgcrypt for things like SSL decryption.
The Libgcrypt library supports sufficiently many ciphers and hashes.
Libgcrypt is widely available and has an active development team.
The Luagcrypt API is simple enough and documented.
The result is luagcrypt which works on the platforms supported by Wireshark (Linux, OS X, Windows). It is used in the KDNET dissector, this commit shows the transformation from lua-lockbox to luagcrypt.

Looking for a good method to transfer critical real time data over internet

I am searching for a good method to transfer data over internet, and I work in C++/windows environment. The data is binary, a compressed blob of an extracted image. Input and requirements are as follows:
6kB/packet # 10 packets/sec (60kBytes per second)
Reliable data transfer
I am new to network programming and so far I could figure out that one of the following methods will be suitable.
Sockets
MSMQ (MS Message Queuing)
The Client runs on a browser (Shows realtime images on browser). While server runs native C++ code. Please let me know if there are any other methods for achieving the same? Which one should I go for and why?
If the server determines the pace at which images are sent, which is what it looks like, a server push style solution would make sense. What most browsers (and even non-browsers) are settling for these days are WebSockets.
The main advantage WebSockets have over most proprietary protocols, apart from becoming a widely adopted standard, is that they run on top of HTTP and can thus permeate (most) proxies and firewalls etc.
On the server side, you could potentially integrate node.js, which allows you to easily implement WebSockets, and comes with a lot of other libraries. It's written in C++, and extensible via C++ and JavaScript, which node.js hosts a VM for. node.js's main feature is being asynchronous at every level, making that style of programming the default.
But of course there are other ways to implement WebSockets on the server side, maybe node.js is more than you need. I have implemented a C++ extension for node.js on Windows and use socket.io to do WebSockets and non-WebSocket transports for older browsers, and that has worked out fine for me.
But that was textual data. In your binary data case, socket.io wouldn't do it, so you could check out other libraries that do binary over WebSockets.
Is there any specific reason why you cannot run a server on your windows machine? 60kb/seconds, looks like some kind of an embedded device?
Based on our description, you ned to show image information, in realtime on a browser. You can possibly use HTTP. but its stateless, meaning once the information is transferred, you lose the connection. You client needs to poll the C++/Windows machine. If you are prety confident the information generated is periodic, you can use this approach. This requires a server, so only if a yes to my first question
A chat protocol. Something like a Jabber client running on your client, and a Jabber server on your C++/Windows machine. Chat protocols allow almost realtime
While it may seem to make sense, I wouldn't use MSMQ in this scenario. You may not run into a problem now, but MSMQ messages are limited in size and you may eventually hit a wall because of this.
I would use TCP for this application, TCP is built with reliability in mind and you can simply feed data through a socket. You may have to figure out a very simple protocol yourself but it should be the best choice.
Unless you are using an embedded device that understands MSMQ out of the box, your best bet to use MSMQ would be to use a proxy and you are then still forced to play with TCP and possibly HTTP.
I do home automation that includes security cameras on my personal time and I use the .net micro framework and even if it did have MSMQ capabilities I still wouldn't use it.
I recommend that you look into MJPEG (Motion JPEG) which sounds exactly like what you would like to do.
http://www.codeproject.com/Articles/371955/Motion-JPEG-Streaming-Server

HTTP server that handles requests through IO devices?

This question can probably only be answered for Unix-like systems that follow the "everything is a file" idiom.
Would it be hard to create a web server that mounts local devices for handling http traffic? It would enable a program to read raw http requests from /dev/httpin (for example) and write the responses to /dev/httpout. I think this would be nice because it would allow me to create a http handler from any programming language that is capable of handling IO streams.
I don't really know where to start on this. Any suggestions on how to setup such a system?
I agree with Javier, check out standards such as FastCGI, Rack, WSGI, or the inchoate OWIN. These interfaces exist basically so that disparate software components can exchange HTTP messages on the same machine, without using network sockets.
Personally, if I was looking to do this, I'd use my favorite JVM library, Restlet (probably with Groovy or Jython) and implement a custom ServerConnector which would construct a Request object and then pass it off to the rest of the framework. This sort of flexibility of architecture is why I like Restlet.

Resources