Skip to content

Commit

Permalink
Merge pull request #11 from bigbrett/demo-examples
Browse files Browse the repository at this point in the history
Demo examples
  • Loading branch information
jpbland1 authored Jun 25, 2024
2 parents 14871cc + 25f9d78 commit 62ebf7c
Show file tree
Hide file tree
Showing 16 changed files with 671 additions and 12 deletions.
98 changes: 98 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
---
Language: Cpp
AccessModifierOffset: -2
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: true
AlignConsecutiveDeclarations: true
AlignEscapedNewlinesLeft: true
AlignOperands: true
AlignTrailingComments: true
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: Empty
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: true
BinPackArguments: 'true'
BinPackParameters: 'true'
BraceWrapping:
AfterCaseLabel: false
AfterClass: false
AfterControlStatement: Never
AfterEnum: false
AfterFunction: true
AfterNamespace: false
AfterObjCDeclaration: false
AfterStruct: false
AfterUnion: false
AfterExternBlock: false
BeforeCatch: false
BeforeElse: true
BeforeLambdaBody: false
BeforeWhile: false
IndentBraces: false
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Custom
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: false
BreakAfterJavaFieldAnnotations: false
BreakStringLiterals: true
ColumnLimit: 80
CommentPragmas: '^ IWYU pragma:'
ConstructorInitializerAllOnOneLineOrOnePerLine: false
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DerivePointerAlignment: false
DisableFormat: false
ExperimentalAutoDetectBinPacking: false
ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ]
IncludeCategories:
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
Priority: 2
- Regex: '^(<|"(gtest|isl|json)/)'
Priority: 3
- Regex: '.*'
Priority: 1
IncludeIsMainRegex: '$'
IndentCaseLabels: true
IndentWidth: 4
IndentWrappedFunctionNames: false
JavaScriptQuotes: Leave
JavaScriptWrapImports: true
KeepEmptyLinesAtTheStartOfBlocks: true
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 2
NamespaceIndentation: None
ObjCBlockIndentWidth: 2
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 60
PointerAlignment: Left
ReflowComments: true
SortIncludes: false
SpaceAfterCStyleCast: false
SpaceAfterTemplateKeyword: true
SpaceBeforeAssignmentOperators: true
SpaceBeforeParens: ControlStatements
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Cpp11
TabWidth: 4
UseTab: Never
---
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# wolfHSM-examples

This repository contains examples code demonstrating how to use various wolfHSM features. The examples provided are split between port-agnostic demo code, and port-specific server/client applications that use the aformentioned demo code.

- `demo/`: port-agnostic demonstration code (`demo/`). This code is intended to be used as a reference for how to use wolfHSM features, and are organized by high-level wolfHSM feature.
- `port/`: Example server and client applications for each port. These applications initialize the server and client context and then run the demo code.

## Current Examples
Currently, the only public example for wolfHSM uses the POSIX simulator. If you are interested in examples for NDA-restricted hardware platforms, please contact us at support@wolfssl.com.

Expand Down
30 changes: 30 additions & 0 deletions demo/client/wh_demo_client_all.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#include "wh_demo_client_all.h"
#include "wh_demo_client_nvm.h"
#include "wh_demo_client_keystore.h"

int wh_DemoClient_All(whClientContext* clientContext)
{
int rc = 0;

/* NVM demos */
rc = wh_DemoClient_Nvm(clientContext);
if (rc != 0) {
return rc;
}

/* Keystore demos */
rc = wh_DemoClient_KeystoreBasic(clientContext);
if (rc != 0) {
return rc;
}
rc = wh_DemoClient_KeystoreCommitKey(clientContext);
if (rc != 0) {
return rc;
}
rc = wh_DemoClient_KeystoreAes(clientContext);
if (rc != 0) {
return rc;
}

return rc;
}
8 changes: 8 additions & 0 deletions demo/client/wh_demo_client_all.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#ifndef CLIENT_DEMO_DRIVER_H_
#define CLIENT_DEMO_DRIVER_H_

#include "wolfhsm/wh_client.h"

int wh_DemoClient_All(whClientContext* clientContext);

#endif /* CLIENT_DEMO_DRIVER_H_ */
7 changes: 7 additions & 0 deletions demo/client/wh_demo_client_counter.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#include "wh_demo_client_counter.h"
#include "wolfhsm/wh_error.h"

int wh_DemoClient_Counter(whClientContext* clientContext)
{
return WH_ERROR_OK;
}
7 changes: 7 additions & 0 deletions demo/client/wh_demo_client_counter.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#ifndef CLIENT_COUNTER_H
#define CLIENT_COUNTER_H
#include "wolfhsm/wh_client.h"

int wh_DemoClient_Counter(whClientContext* clientContext);

#endif /* CLIENT_COUNTER_H */
7 changes: 7 additions & 0 deletions demo/client/wh_demo_client_crypto.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#include "wh_demo_client_crypto.h"
#include "wolfhsm/wh_error.h"

int wh_DemoClient_Crypto(whClientContext* clientContext);
{
return WH_ERROR_OK;
}
7 changes: 7 additions & 0 deletions demo/client/wh_demo_client_crypto.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#ifndef CLIENT_CRYPTO_H_
#define CLIENT_CRYPTO_H_
#include "wolfhsm/wh_client.h"

int wh_DemoClient_Crypto(whClientContext* clientContext);

#endif /* CLIENT_CRYPTO_H_ */
Loading

0 comments on commit 62ebf7c

Please sign in to comment.