+ } else {
+ fprintf(stderr, "Couldn't create `%s' directory due to a wrong uid!\n",
+ friendsfilename);
+ return FALSE;
+ }
+ } else {
+ fprintf(stderr, "%s\n", strerror(errno));
+ return FALSE;
+ }
+ }
+
+ /*
+ * Check Public and Private keys
+ */
+ snprintf(file_public_key, sizeof(file_public_key) - 1, "%s%s",
+ filename, SILC_CLIENT_PUBLIC_KEY_NAME);
+ snprintf(file_private_key, sizeof(file_private_key) - 1, "%s%s",
+ filename, SILC_CLIENT_PRIVATE_KEY_NAME);
+
+ if ((stat(file_public_key, &st)) == -1) {
+ /* If file doesn't exist */
+ if (errno == ENOENT) {
+ fprintf(stdout, "Running SILC for the first time\n");
+ silc_create_key_pair(SILC_CLIENT_DEF_PKCS,
+ SILC_CLIENT_DEF_PKCS_LEN,
+ file_public_key, file_private_key, NULL,
+ NULL, NULL, NULL, NULL, FALSE);
+ printf("Press <Enter> to continue...\n");
+ getchar();
+ } else {
+ fprintf(stderr, "%s\n", strerror(errno));
+ return FALSE;
+ }
+ }
+
+ /* Check the owner of the public key */
+ if (st.st_uid != 0 && st.st_uid != pw->pw_uid) {
+ fprintf(stderr, "You don't seem to own your public key!?\n");
+ return FALSE;
+ }
+
+ if ((stat(file_private_key, &st)) == -1) {
+ /* If file doesn't exist */
+ if (errno == ENOENT) {
+ fprintf(stdout, "Your private key doesn't exist\n");
+ silc_create_key_pair(SILC_CLIENT_DEF_PKCS,
+ SILC_CLIENT_DEF_PKCS_LEN,
+ file_public_key, file_private_key, NULL,
+ NULL, NULL, NULL, NULL, FALSE);
+ printf("Press <Enter> to continue...\n");
+ getchar();
+ } else {
+ fprintf(stderr, "%s\n", strerror(errno));