multiparty encryption and decryption - encryption

Is is possible to send a single encrypted data message to multiple users and the users receiving the message can only decrypt certain parts of the message depending on their rights.
For example, I send a message "Hello World", User A could decrypt can receive the whole message(hello world), but user B only can decrypt certain part and receive the message as "hello" only.

Related

Does HMAC encrypts the original Plaintext message?

So my Question is a combination of 3:
Does HMAC hashing also hash the message along with the Secret key send to the recipient? Or just the Secret key is hashed, leaving the message as Plaintext?
If ONLY the secret key is hashed(not hashing the message), doesn't it makes the message vulnerable to unauthorized people(attackers) if they get access to that Plaintext and easily understand it?
If both(message + secret key) are concatenated to form the hash, how HMAC is different from the 'SALTING' method?
HMAC authenticates a message. It does not encrypt it. If you want to encrypt the message, encrypt it first, and then apply an HMAC. (This is generally called the "encrypt-then-MAC" construction.)
The point of authentication is to demonstrate that a message has not been altered. The point of encryption is to prevent other parties from reading the message. Often these go together, but they don't have to.

Is it okay to encrypt server-side when using HTTPS?

I am creating a messaging service for an app I'm developing. Because of the nature of the messages, it is important not only to verify users, but also verify what conversation the message belongs to. So right now I create a public/private key pair for each conversation and use it to encrypt/decrypt the messages. Basically when a user is logged in, they have access to the key pairs of the conversations they belong to, but those key pairs only work for that particular conversation. This allows access to be granted/denied to particular conversations while keeping other conversations between those same parties intact. Right now the data flow is as follows:
Send:
message sent to server => message encrypted based on user's public key and signed using secret key => encrypted message saved to database
Receive:
server receives message from database => server verifies signature using public key and decrypts message using secret key => decrypted message sent to client
All the encryption/decryption on the server is dependent upon the user's JWT token being authenticated.
I have two main questions: 1.) Is it okay to encrypt on the server since the communication between it and the client is using TLS? 2.) Should the keys be stored on the server or in the database?
Also, if this method is insecure, incorrect, or flat out just dumb please let me know.
Thanks in advance.

rsa keys verification

So I'm developing my messanging app with encryption evolved using RSA. Currently I came up with this algorithm:
= Update for auth =
Screenshot:
In this case private keys are generated only from password, and server knows only password hash just to authorize users (unhashed password is never transmitted to server), therefore is unable to generate private keys or decrypt any old message. If server will fake a public key recipent will be unable to verify signature encrypted with sender's private key.
The problem is that server can fake a sender's private, public key and password when he signs up on a service or requests a password change and recipent will be unable to detect it. So, how can I verify that keys were not faked by the server?
So, how can I verify that keys were not faked by the server?
You cannot. So long as the clients only communicate with the server, there's no way for them to distinguish between a "real" remote user and one that's being MITMed or otherwise faked by the server.
I see a couple other serious potential issues here:
Sending an unsalted hash of a password over the wire (during the login process) is hardly better than sending the password in the clear. An attacker can sniff the hash off the wire to log in -- they don't need the actual password! -- and a non-iterated SHA256 is highly vulnerable to brute force attacks.
"private key from pass" (also in the login process) implies that you're using some sort of KDF to generate a private key from the user's password. This has multiple negative implications:
Users are generally pretty bad at choosing passwords. This implies that the private keys will also be weak.
If two users happen to use the same password, they will end up with the same private key.
Any user can attack the password (and hence the private key) of any other user that they've communicated with by running the KDF on candidate passwords.
There is no process specified for negotiating a symmetric encryption key. Using RSA to encrypt messages directly limits each message to the size of the key, and makes it vulnerable to numerous attacks if the data being encrypted is not both random and unique.
In the message exchange, the user sends the server two copies of every message -- one encrypted to the target user's private key, one encrypted to their own private key. In some situations, this may make it possible to recover the message.

How or What is the best way to pass an encryption key?

Ok. so, encrypted data is sent from the computer to the server and spread to other computers. And, let say there is a person in the middle attack?
Here is where I'm confuse; The client/server need to decrypt the data with the key, but if the key can be seen by the client computer then the attacker can see it in the data as well. The key can be encrypted, but another key would have to be sent un-encrypted. so how do you pass the "key" to decrypt the data?
So when I hear new chat system saying they are enprypted their client messages; I'm wondering, how are they doing it? When hacker can try to find the key in thier data and decrypt the message.

How to do encryption and decryption in query string value?

I want to use an two way algorithm(means i should both encrypt and decrypt). The below is my
Scenario:
I have a application where user can register by providing their First name, Last name and Email address. Once the data is stored in DB a mail will be sent to Registered User's Registered email address with the below content
Please click the link to configure your account:
http://mysitename.com?somepage.aspx?enc=EmailaddresinencyptedFormat
what i am doing is attaching registered user's registered email address in query string in encrypted format. user will click the following link and will be redirected to a configuration page where user enters his/her username,secretquestion. Then the input data and the encrypted emailaddress in the querystring will be passed to service and the service will decrypt them and validate the emailaddress.
Required:
What algorithm can be used to encrypt and decrpt? let me know BEST algorithm for this scenario.
Please help me out
Instead of encrypting the email address, place in the database a sufficiently large, 100% random value (such as a GUID or UUID), and associate it with a salted hash of the email address of the person who signed up. Send the GUID to the user in the link. Then, when they finish, you can saltedly hash the email they filled in on the second link and match it to the email address.
Since it is random there is no possibility of guessing random urls and stumbling across other people's registrations, and even if the database leaks only salted hashed emails are exposed, which cannot be decrypted into an email.
http://www.martinstoeckli.ch/php/php.html#bcrypt is a good resource on what hashing is and what it's for.

Resources