forked from cory/tildefriends
		
	Yikes. I broke appending?
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4351 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
		
							
								
								
									
										11
									
								
								src/ssb.c
									
									
									
									
									
								
							
							
						
						
									
										11
									
								
								src/ssb.c
									
									
									
									
									
								
							| @@ -1683,8 +1683,7 @@ bool tf_ssb_append_message_with_keys(tf_ssb_t* ssb, const char* author, const ui | |||||||
| 	{ | 	{ | ||||||
| 		JS_SetPropertyStr(context, root, "previous", JS_NULL); | 		JS_SetPropertyStr(context, root, "previous", JS_NULL); | ||||||
| 	} | 	} | ||||||
| 	JSValue authorstr = JS_NewString(context, author); | 	JS_SetPropertyStr(context, root, "author", JS_NewString(context, author)); | ||||||
| 	JS_SetPropertyStr(context, root, "author", authorstr); |  | ||||||
| 	JS_SetPropertyStr(context, root, "sequence", JS_NewInt64(context, previous_sequence + 1)); | 	JS_SetPropertyStr(context, root, "sequence", JS_NewInt64(context, previous_sequence + 1)); | ||||||
|  |  | ||||||
| 	int64_t now = (int64_t)time(NULL); | 	int64_t now = (int64_t)time(NULL); | ||||||
| @@ -1706,9 +1705,6 @@ bool tf_ssb_append_message_with_keys(tf_ssb_t* ssb, const char* author, const ui | |||||||
| 		tf_printf("crypto_sign_detached failed\n"); | 		tf_printf("crypto_sign_detached failed\n"); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	JS_FreeCString(context, json); |  | ||||||
| 	JS_FreeValue(context, jsonval); |  | ||||||
|  |  | ||||||
| 	char signature_base64[crypto_sign_BYTES * 2]; | 	char signature_base64[crypto_sign_BYTES * 2]; | ||||||
| 	tf_base64_encode(signature, sizeof(signature), signature_base64, sizeof(signature_base64)); | 	tf_base64_encode(signature, sizeof(signature), signature_base64, sizeof(signature_base64)); | ||||||
| 	strcat(signature_base64, ".sig.ed25519"); | 	strcat(signature_base64, ".sig.ed25519"); | ||||||
| @@ -1733,6 +1729,8 @@ bool tf_ssb_append_message_with_keys(tf_ssb_t* ssb, const char* author, const ui | |||||||
| 	else | 	else | ||||||
| 	{ | 	{ | ||||||
| 		tf_printf("Failed to verify message signature.\n"); | 		tf_printf("Failed to verify message signature.\n"); | ||||||
|  | 		tf_printf("json = %s\n", json); | ||||||
|  | 		tf_printf("sig = %s\n", signature_base64); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	if (!stored && out_id && out_id_size) | 	if (!stored && out_id && out_id_size) | ||||||
| @@ -1740,6 +1738,9 @@ bool tf_ssb_append_message_with_keys(tf_ssb_t* ssb, const char* author, const ui | |||||||
| 		*out_id = '\0'; | 		*out_id = '\0'; | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  | 	JS_FreeCString(context, json); | ||||||
|  | 	JS_FreeValue(context, jsonval); | ||||||
|  |  | ||||||
| 	JS_FreeValue(context, root); | 	JS_FreeValue(context, root); | ||||||
| 	return stored; | 	return stored; | ||||||
| } | } | ||||||
|   | |||||||
| @@ -118,9 +118,9 @@ static JSValue _tf_ssb_appendMessageWithIdentity(JSContext* context, JSValueCons | |||||||
| 		uint8_t private_key[crypto_sign_SECRETKEYBYTES]; | 		uint8_t private_key[crypto_sign_SECRETKEYBYTES]; | ||||||
| 		if (tf_ssb_db_identity_get_private_key(ssb, user, id, private_key, sizeof(private_key))) | 		if (tf_ssb_db_identity_get_private_key(ssb, user, id, private_key, sizeof(private_key))) | ||||||
| 		{ | 		{ | ||||||
| 			char id[k_id_base64_len] = { 0 }; | 			char message_id[k_id_base64_len] = { 0 }; | ||||||
| 			tf_ssb_append_message_with_keys(ssb, id, private_key, argv[2], id, sizeof(id)); | 			tf_ssb_append_message_with_keys(ssb, id, private_key, argv[2], message_id, sizeof(message_id)); | ||||||
| 			result = JS_NewString(context, id); | 			result = JS_NewString(context, message_id); | ||||||
| 		} | 		} | ||||||
| 		else | 		else | ||||||
| 		{ | 		{ | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user