Line 7:
Line 7:
char content_hash[20];
char content_hash[20];
};
};
−
+
int verify_cert (struct rsa_cert cert) {
int verify_cert (struct rsa_cert cert) {
char *cert_hash=SHA1(cert.metadata + cert.content_hash);
char *cert_hash=SHA1(cert.metadata + cert.content_hash);
char *sig_hash=rsa_decrypt(cert.rsa_signature, cert.key_id);
char *sig_hash=rsa_decrypt(cert.rsa_signature, cert.key_id);
−
+
if (strncmp(cert_hash, sig_hash, SHA1_LENGTH) == 0) {
if (strncmp(cert_hash, sig_hash, SHA1_LENGTH) == 0) {
return CERT_OK;
return CERT_OK;
Line 18:
Line 18:
}
}
}
}
−
+
int is_a_valid_disc(struct rsa_cert cert, char *disc_hash) {
int is_a_valid_disc(struct rsa_cert cert, char *disc_hash) {
if(memcmp(disc_hash, cert.content_hash, SHA1_LENGTH) != 0) {
if(memcmp(disc_hash, cert.content_hash, SHA1_LENGTH) != 0) {
return DISC_BAD;
return DISC_BAD;
}
}
−
+
if(verify_cert (cert) == CERT_BAD) {
if(verify_cert (cert) == CERT_BAD) {
return DISC_BAD;
return DISC_BAD;
} else {
} else {
return DISC_OK;
return DISC_OK;
−
}
+
}
+
}