Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
5b01527
Initial commit
ueno Sep 17, 2025
15b65db
Initial import
ueno Sep 17, 2025
79191d6
README.md: some_function → this_function
ueno Sep 17, 2025
8881185
README.md: Mention low-level macro usage
ueno Sep 17, 2025
7069f87
crau.c: Fix unterminated #ifdef
ueno Sep 17, 2025
39d01a4
crau.h: Clarify the scope of crau_context_t
ueno Sep 17, 2025
4e4df74
crau.c: Move CRAU_MAYBE_UNUSED definition right before the usage
ueno Sep 17, 2025
45a2792
README.md: Fix typo
ueno Sep 19, 2025
4e3c5b1
Infer current context from the call frame
ueno Sep 23, 2025
8b62f41
README.md: Remove context argument from crau_new_context_with_data
ueno Sep 23, 2025
50d43d6
Suggest defining configuration macros upon error
ueno Sep 23, 2025
330c5f2
Update doc comments
ueno Sep 23, 2025
183bd9d
Swap the order of key_ptr and value type
ueno Sep 23, 2025
4b0d0db
Don't include "macros.h" in "crau.h"
ueno Sep 23, 2025
5db19f2
Fix the previous commit
ueno Sep 24, 2025
dd8eeed
Fix macro naming
ueno Sep 24, 2025
24d0c45
Don't use <assert.h>
ueno Sep 24, 2025
913dee9
macros: Fix typo
ueno Sep 24, 2025
7730a6a
Add CRAU_AUTO_CONTEXT and embed it as an argument
ueno Sep 24, 2025
74ae381
.dir-locals.el: Add indentation for Emacs
ueno Sep 24, 2025
5d8b84e
Define crau_new_context_with_data as a wrapper macro
ueno Sep 24, 2025
ebb0fa6
Make first argument of crau_data as const
ueno Sep 24, 2025
4df495e
Pacify -Wbad-function-cast
ueno Sep 24, 2025
ad8daee
Fix element counting in accumulate_datav
ueno Sep 25, 2025
61fe880
Fix doc comment of CRAU_AUTO_CONTEXT
ueno Sep 30, 2025
b64ad5a
Fix type confusion between crau.h and BPF program
ueno Sep 30, 2025
41b52e3
Make it header-only and relicense as MIT OR Unlicense
ueno Oct 6, 2025
3ce9f76
Minor style fixes
ueno Oct 6, 2025
f2e84a4
Remove crau.c
ueno Oct 6, 2025
23376d0
Fix compilation without ENABLE_CRYPTO_AUDITING
ueno Oct 6, 2025
dab2b97
Error out if HAVE_SYS_SDT_H is not defined while it is used
ueno Oct 6, 2025
e9dd944
Include <sys/sdt.h> unconditionally, check DTRACE_PROBE
ueno Oct 8, 2025
cfc9e31
crau.h: Make functions take a stack argument
ueno Oct 14, 2025
81f5237
crau.h: Drop crau_context_t, always assume it to be long
ueno Oct 14, 2025
5027e55
crau.h: Fix the previous commit
ueno Oct 14, 2025
5c13217
crau: fix compilation with gcc < 11
jolivain Dec 1, 2025
5dc2892
Add 'dist/crau/' from commit '5c13217b320dd68c465368aa3f02763302a72d20'
ueno Dec 1, 2025
fc96dbf
Remove dist/audit.h
ueno Dec 1, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
91 changes: 0 additions & 91 deletions dist/audit.h

This file was deleted.

1 change: 1 addition & 0 deletions dist/crau/.dir-locals.el
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
((c-mode . ((c-file-style . "linux"))))
21 changes: 21 additions & 0 deletions dist/crau/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2025 Daiki Ueno

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
76 changes: 76 additions & 0 deletions dist/crau/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# crau

`crau` is a header-only library to help define
[crypto-auditing][crypto-auditing] probes in C applications.

## Getting started

1. Define `ENABLE_CRYPTO_AUDITING` to 1, e.g., through
`<config.h>`. Also check if `<sys/sdt.h>` is installed and
`DTRACE_PROBE*` macros are defined there.

1. Include `<crau/crau.h>`. One of the C files should define
`CRAU_IMPLEMENTATION` to get the functions defined. Also decide
where to manage the context stack: if it is part of another struct,
add field with type `struct crau_context_stack_st`; if it is
maintained globally as thread-local, define a thread-local
variable.

1. (Optional) Customize the implementation with configuration macros,
e.g., `CRAU_CONTEXT_STACK_DEPTH` for your needs. See
`<crau/crau.h>` for the details.

1. Instrument the code as follows. See `<crau/crau.h>` and
`<crau/macros.h>` for the documentation:

```c
/* Public key signing operation starts (but the algorithm is not known yet) */
crau_new_context_with_data(
&stack,
"name", CRAU_STRING, "pk::sign",
NULL)
...
/* Signing algorithm and bits are known at this point */
crau_data(
&stack,
"pk::algorithm", CRAU_STRING, "mldsa",
"pk::bits", CRAU_WORD, 1952 * 8,
NULL)

/* Do the operation */
sig = mldsa_sign(...);

/* Pop the operation context */
crau_pop_context(&stack);
```

## Low level macros

Instead of using those helper functions (`crau_*`), it is also
possible to directly instrument the library with `CRAU_` macros
defined in `macros.h`:

```c
/* Public key signing operation starts (but the algorithm is not known yet) */
CRAU_NEW_CONTEXT_WITH_DATAV(
(long)this_function,
(long)parent_function,
CRAU_STRING_DATA("name", "pk::sign"));
...
/* Signing algorithm and bits are known at this point */
CRAU_DATAV(
(long)this_function,
CRAU_STRING_DATA("pk::algorithm", "mldsa"),
CRAU_WORD_DATA("pk::bits", 1952 * 8))

/* Do the operation */
sig = mldsa_sign(...);
```

Note that those macros don't do context management.

## License

MIT or Unlicense

[crypto-auditing]: https://github.com/latchset/crypto-auditing
24 changes: 24 additions & 0 deletions dist/crau/UNLICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
This is free and unencumbered software released into the public domain.

Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.

In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the
software to the public domain. We make this dedication for the benefit
of the public at large and to the detriment of our heirs and
successors. We intend this dedication to be an overt act of
relinquishment in perpetuity of all present and future rights to this
software under copyright law.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.

For more information, please refer to <https://unlicense.org/>
Loading