Skip to content

Commit

Permalink
Doc: documents query files
Browse files Browse the repository at this point in the history
  • Loading branch information
spalmer25 committed Mar 6, 2024
1 parent 0b77b6e commit 3054efe
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 19 deletions.
10 changes: 0 additions & 10 deletions src/apdu_baking.h

This file was deleted.

16 changes: 8 additions & 8 deletions src/apdu_baking.c → src/apdu_query.c
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
#include "apdu_baking.h"
#include "apdu_query.h"

#include "apdu.h"
#include "baking_auth.h"
#include "globals.h"
#include "os_cx.h"
#include "protocol.h"
#include "to_string.h"
#include "ui.h"

#include <string.h>

/**
* @brief Inserts big endian word in the apdu response
*
* @param tx: current offset of the apdu response
* @param word: big endian word
* @return size_t: updated offset of the apdu response
*/
size_t send_word_big_endian(size_t tx, uint32_t word) {
char word_bytes[sizeof(word)];

Expand Down
48 changes: 48 additions & 0 deletions src/apdu_query.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#pragma once

#include <stddef.h>
#include <stdint.h>

/**
* @brief Handles QUERY_AUTH instruction
*
* Fills apdu response with the authorized key path
*
* @param instruction: apdu instruction
* @param flags: io flags
* @return size_t: offset of the apdu response
*/
size_t handle_apdu_query_auth_key(uint8_t instruction, volatile uint32_t* flags);

/**
* @brief Handles QUERY_AUTH_KEY_WITH_CURVE instruction
*
* Fills apdu response with the authorized key path and its curve
*
* @param instruction: apdu instruction
* @param flags: io flags
* @return size_t: offset of the apdu response
*/
size_t handle_apdu_query_auth_key_with_curve(uint8_t instruction, volatile uint32_t* flags);

/**
* @brief Handles QUERY_MAIN_HWM instruction
*
* Fills apdu response with main HWM
*
* @param instruction: apdu instruction
* @param flags: io flags
* @return size_t: offset of the apdu response
*/
size_t handle_apdu_main_hwm(uint8_t instruction, volatile uint32_t* flags);

/**
* @brief Handles QUERY_ALL_HWM instruction
*
* Fills apdu response with main HWM, test HWM and main chain id
*
* @param instruction: apdu instruction
* @param flags: io flags
* @return size_t: offset of the apdu response
*/
size_t handle_apdu_all_hwm(uint8_t instruction, volatile uint32_t* flags);
2 changes: 1 addition & 1 deletion src/main.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "apdu_baking.h"
#include "apdu_hmac.h"
#include "apdu_pubkey.h"
#include "apdu_query.h"
#include "apdu_reset.h"
#include "apdu_setup.h"
#include "apdu_sign.h"
Expand Down

0 comments on commit 3054efe

Please sign in to comment.