1.1 --- a/src/pgp_netpgp.c Tue Aug 02 12:08:23 2016 +0200
1.2 +++ b/src/pgp_netpgp.c Tue Aug 02 14:47:55 2016 +0200
1.3 @@ -1644,3 +1644,57 @@
1.4
1.5 return PEP_STATUS_OK;
1.6 }
1.7 +
1.8 +PEP_STATUS pgp_key_created(
1.9 + PEP_SESSION session,
1.10 + const char *fprstr,
1.11 + time_t *created
1.12 + )
1.13 +{
1.14 + uint8_t fpr[PGP_FINGERPRINT_SIZE];
1.15 + pgp_key_t *key;
1.16 + size_t length;
1.17 + unsigned from = 0;
1.18 +
1.19 + PEP_STATUS status = PEP_STATUS_OK;
1.20 +
1.21 + assert(session);
1.22 + assert(fprstr);
1.23 + assert(created);
1.24 +
1.25 + if (!session || !fprstr || !created)
1.26 + return PEP_UNKNOWN_ERROR;
1.27 +
1.28 + *created = 0;
1.29 +
1.30 + if(pthread_mutex_lock(&netpgp_mutex)){
1.31 + return PEP_UNKNOWN_ERROR;
1.32 + }
1.33 +
1.34 + if (!str_to_fpr(fprstr, fpr, &length)) {
1.35 + status = PEP_ILLEGAL_VALUE;
1.36 + goto unlock_netpgp;
1.37 + }
1.38 +
1.39 + key = pgp_getkeybyfpr(
1.40 + netpgp.io,
1.41 + netpgp.pubring,
1.42 + fpr, length, &from, NULL,0,0);
1.43 +
1.44 + if (key)
1.45 + {
1.46 + *created = (time_t) key->key.pubkey.birthtime;
1.47 + }
1.48 + else
1.49 + {
1.50 + status = PEP_KEY_NOT_FOUND;
1.51 + goto unlock_netpgp;
1.52 + }
1.53 +
1.54 +
1.55 +
1.56 +unlock_netpgp:
1.57 + pthread_mutex_unlock(&netpgp_mutex);
1.58 +
1.59 + return status;
1.60 +}
2.1 --- a/src/pgp_netpgp.h Tue Aug 02 12:08:23 2016 +0200
2.2 +++ b/src/pgp_netpgp.h Tue Aug 02 14:47:55 2016 +0200
2.3 @@ -70,3 +70,10 @@
2.4 const char *fpr,
2.5 bool *revoked
2.6 );
2.7 +
2.8 +PEP_STATUS pgp_key_created(
2.9 + PEP_SESSION session,
2.10 + const char *fprstr,
2.11 + time_t *created
2.12 + );
2.13 +