Domain.com has been contracted by the local hospital to create an application that forwards private
patient information to various insurance providers.
The patient information is sent via a secured VPN to ensure confidentiality.
You also need to guarantee data integrity, and verify that the patient data originated from the local hospital.
To achieve this objective, you elect to utilize asymmetric encryption and a digital signature technology.
What code would you use to complete your task?
A.
public byte [] SignAndHash(byte [] PatientInfo, RSAParameters RSAInfo){
RSACryptoServiceProvider RSAProvider = new RSACryptoServiceProvider ();
RSAProvider.ImportParameters(RSAInfo);
Return RSAProvider.Encrypt(PatientInfo, true);
}
B.
public byte [] SignAndHash(byte [] PatientInfo, DSAParameters DSAInfo){
DSACryptoServiceProvider DSAProvider = new DSACryptoServiceProvider();
DSAProvider.ImportParameters(DSAInfo);
Return DSAProvider.SignHash(PatientInfo);
}
C.
public byte [] SignAndHash(byte [] PatientInfo, RSAParameters RSAInfo){
RSACryptoServiceProvider RSAProvider = new RSACryptoServiceProvider();
RSAProvider.ImportParameters(RSAInfo);
Return RSAProvider.SignEncrypt(PatientInfo, true);
}
D.
public byte [] SignAndHash(byte [] PatientInfo, DSAParameters DSAInfo){
DSACryptoServiceProvider DSAProvider = new DSACryptoServiceProvider();
DSAProvider.ImportParameters(DSAInfo);
Return DSAProvider.SignData(PatientInfo);
}
Explanation:
The DSACryptoServiceProvider class represents a managed cryptographic provider of the Digital Signature Algorithm (DSA) asymmetric algorithm. The DSA asymmetric algorithm is commonly used for digital signatures and data integrity, supporting 1024 bit keys.
When instantiating a DSACryptoServiceProvider object, a public/private key pair is generated and a default hash is assigned.
Thus, to use a particular private key to sign data, a public key to verify data, or a particular hash, you must invoke the ImportParemeters method for the current DSACryptoServiceProvider to load custom settings.
The SignData method takes a byte array representing the original data and returns the hashed and then signed byte array.
Incorrect Answers:
A, C: You should not use the code fragments that specify the RSACryptoServiceProvider object because the method invocations are incorrect.
B: The SignHash method is used to sign a message digest, not the original data.
D