|
|
@ -99,7 +99,7 @@ int member_join(char *buffer) { |
|
|
break; |
|
|
break; |
|
|
case ISSUERPUB: |
|
|
case ISSUERPUB: |
|
|
if (0 == strncasecmp("PUBLISH", buffer, 7)) { |
|
|
if (0 == strncasecmp("PUBLISH", buffer, 7)) { |
|
|
printf("ISSUER > MEMBER: %s", buffer); |
|
|
printf("ISSUER > MEMBER: %s\n", buffer); |
|
|
uint8_t binbuf[MAX_BUFSIZE]; |
|
|
uint8_t binbuf[MAX_BUFSIZE]; |
|
|
char *current = &buffer[8]; |
|
|
char *current = &buffer[8]; |
|
|
ecdaa_decode(current, binbuf, ECDAA_ISSUER_PUBLIC_KEY_FP256BN_LENGTH); |
|
|
ecdaa_decode(current, binbuf, ECDAA_ISSUER_PUBLIC_KEY_FP256BN_LENGTH); |
|
|
@ -124,7 +124,7 @@ int member_join(char *buffer) { |
|
|
break; |
|
|
break; |
|
|
case APPEND: |
|
|
case APPEND: |
|
|
if (0 == strncasecmp("JOINSTART", buffer, 9)) { |
|
|
if (0 == strncasecmp("JOINSTART", buffer, 9)) { |
|
|
printf("ISSUER > MEMBER: %s", buffer); |
|
|
printf("ISSUER > MEMBER: %s\n", buffer); |
|
|
member_joinappend(buffer); |
|
|
member_joinappend(buffer); |
|
|
member.state = JOINPROCEED; |
|
|
member.state = JOINPROCEED; |
|
|
} else { |
|
|
} else { |
|
|
@ -135,7 +135,7 @@ int member_join(char *buffer) { |
|
|
break; |
|
|
break; |
|
|
case JOINPROCEED: |
|
|
case JOINPROCEED: |
|
|
if (0 == strncasecmp("JOINPROCEED", buffer, 11)) { |
|
|
if (0 == strncasecmp("JOINPROCEED", buffer, 11)) { |
|
|
printf("ISSUER > MEMBER: %s", buffer); |
|
|
printf("ISSUER > MEMBER: %s\n", buffer); |
|
|
member_joinfinish(buffer); |
|
|
member_joinfinish(buffer); |
|
|
member.state = JOINED; |
|
|
member.state = JOINED; |
|
|
ret = 1; |
|
|
ret = 1; |
|
|
@ -258,11 +258,14 @@ int member_joinfinish(char *buffer) { |
|
|
bincur = &binbuf[ECDAA_CREDENTIAL_FP256BN_LENGTH]; |
|
|
bincur = &binbuf[ECDAA_CREDENTIAL_FP256BN_LENGTH]; |
|
|
ecdaa_decode(current, bincur, ECDAA_CREDENTIAL_FP256BN_SIGNATURE_LENGTH); |
|
|
ecdaa_decode(current, bincur, ECDAA_CREDENTIAL_FP256BN_SIGNATURE_LENGTH); |
|
|
ret = ecdaa_credential_FP256BN_deserialize_with_signature(&member.cred, &member.mpk, &member.ipk.gpk, binbuf, bincur); |
|
|
ret = ecdaa_credential_FP256BN_deserialize_with_signature(&member.cred, &member.mpk, &member.ipk.gpk, binbuf, bincur); |
|
|
|
|
|
bzero(buffer, MAX_BUFSIZE); |
|
|
if(-1 == ret) { |
|
|
if(-1 == ret) { |
|
|
printf("member_joinfinish: credential is malformed!\n"); |
|
|
printf("member_joinfinish: credential is malformed!\n"); |
|
|
|
|
|
strncpy(buffer, "ERR", 3); |
|
|
ret = -1; |
|
|
ret = -1; |
|
|
} else if(-2 == ret) { |
|
|
} else if(-2 == ret) { |
|
|
printf("member_joinfinish: siganture of credential is invalid\n"); |
|
|
printf("member_joinfinish: siganture of credential is invalid\n"); |
|
|
|
|
|
strncpy(buffer, "ERR", 3); |
|
|
ret = -1; |
|
|
ret = -1; |
|
|
} |
|
|
} |
|
|
printf("member_joinfinish: writing key-pair and credential to disk\n"); |
|
|
printf("member_joinfinish: writing key-pair and credential to disk\n"); |
|
|
@ -270,9 +273,11 @@ int member_joinfinish(char *buffer) { |
|
|
0 != ecdaa_member_secret_key_FP256BN_serialize_file(member_secret_key_file, &member.msk) || |
|
|
0 != ecdaa_member_secret_key_FP256BN_serialize_file(member_secret_key_file, &member.msk) || |
|
|
0 != ecdaa_credential_FP256BN_serialize_file(member_credential_file, &member.cred)) { |
|
|
0 != ecdaa_credential_FP256BN_serialize_file(member_credential_file, &member.cred)) { |
|
|
printf("issuer_setup: Error saving key-pair or credential to disk\n"); |
|
|
printf("issuer_setup: Error saving key-pair or credential to disk\n"); |
|
|
return -1; |
|
|
strncpy(buffer, "ERR", 3); |
|
|
|
|
|
ret = -1; |
|
|
|
|
|
} else { |
|
|
|
|
|
strncpy(buffer, "OK", 2); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return ret; |
|
|
return ret; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|