Exemplo n.º 1
0
//emits a bunch of session debugging information to console.
void session_debug(session *mySession) {
#ifdef DEBUG_CRYPTO

    debug_array("foreign-public-key",mySession->foreign_public_key,32);
    debug_array("session-nonce",mySession->session_nonce,24);
    debug_array("shared-key",mySession->streambox.shared_key,32);
    debug_array("streambox->fpk",mySession->streambox.foreign_public_key,32);
    debug_array("streambox->secret_streambox->nonce", mySession->streambox.secret_streambox.nonce, 24);
    debug_array("streambox->secret_streambox->salsa20_state", mySession->streambox.secret_streambox.salsa20_state, 16);
    debug_array("streambox->secret_streambox->firstkey",mySession->streambox.secret_streambox.firstkey,32);
    debug_array("streambox->secret_streambox->secondkey",mySession->streambox.secret_streambox.secondkey,32);
#endif
}
Exemplo n.º 2
0
void debug_json_element(struct json_element json_element, int depth) {
    int i;
    for (i = 0; i < depth; ++i) {
        printf(" ");
    }
    if (json_element.type == JSON_TYPE_STRING) {
        printf("%s\n", json_element.u.s);
    }
    else {
        debug_array(json_element.u.array, depth);
    }
}
Exemplo n.º 3
0
void debug(struct json_result *result) {
    int i;

    printf("Strings:\n");
    for (i = 0; i < result->i_string; ++i) {
        printf("%s\n", result->strings[i]);
    }

    printf("---\n\n");
    for (i = 0; i < result->i_array; ++i) {
        printf("\narray %d\n", i);
        debug_array(result->arrays[i], 0);
        printf("\n");
    }
}
Exemplo n.º 4
0
void session_send(session *session, unsigned char *packet, unsigned char *plaintext, unsigned int plaintext_length) {
#ifdef DEBUG_CRYPTO
    printf("Before sending first packet.\n");
    session_debug(session);
#endif
    
    crypto_streambox_encrypt(&session->streambox, packet, plaintext, plaintext_length);
#ifdef DEBUG_CRYPTO
    printf("After sending first packet.\n");
    session_debug(session);
    debug_array("Complete packet:", packet, plaintext_length+MESSAGE_PADDING);
#endif
    
    
}