Skip to content

Commit e85da67

Browse files
committed
Initial commit. Moved all the code and setup flipper firmware as submodule
0 parents  commit e85da67

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+4507
-0
lines changed

.clang-format

+191
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,191 @@
1+
---
2+
Language: Cpp
3+
AccessModifierOffset: -4
4+
AlignAfterOpenBracket: AlwaysBreak
5+
AlignArrayOfStructures: None
6+
AlignConsecutiveMacros: None
7+
AlignConsecutiveAssignments: None
8+
AlignConsecutiveBitFields: None
9+
AlignConsecutiveDeclarations: None
10+
AlignEscapedNewlines: Left
11+
AlignOperands: Align
12+
AlignTrailingComments: false
13+
AllowAllArgumentsOnNextLine: true
14+
AllowAllParametersOfDeclarationOnNextLine: false
15+
AllowShortEnumsOnASingleLine: true
16+
AllowShortBlocksOnASingleLine: Never
17+
AllowShortCaseLabelsOnASingleLine: false
18+
AllowShortFunctionsOnASingleLine: None
19+
AllowShortLambdasOnASingleLine: All
20+
AllowShortIfStatementsOnASingleLine: WithoutElse
21+
AllowShortLoopsOnASingleLine: true
22+
AlwaysBreakAfterDefinitionReturnType: None
23+
AlwaysBreakAfterReturnType: None
24+
AlwaysBreakBeforeMultilineStrings: false
25+
AlwaysBreakTemplateDeclarations: Yes
26+
AttributeMacros:
27+
- __capability
28+
BinPackArguments: false
29+
BinPackParameters: false
30+
BraceWrapping:
31+
AfterCaseLabel: false
32+
AfterClass: false
33+
AfterControlStatement: Never
34+
AfterEnum: false
35+
AfterFunction: false
36+
AfterNamespace: false
37+
AfterObjCDeclaration: false
38+
AfterStruct: false
39+
AfterUnion: false
40+
AfterExternBlock: false
41+
BeforeCatch: false
42+
BeforeElse: false
43+
BeforeLambdaBody: false
44+
BeforeWhile: false
45+
IndentBraces: false
46+
SplitEmptyFunction: true
47+
SplitEmptyRecord: true
48+
SplitEmptyNamespace: true
49+
BreakBeforeBinaryOperators: None
50+
BreakBeforeConceptDeclarations: true
51+
BreakBeforeBraces: Attach
52+
BreakBeforeInheritanceComma: false
53+
BreakInheritanceList: BeforeColon
54+
BreakBeforeTernaryOperators: false
55+
BreakConstructorInitializersBeforeComma: false
56+
BreakConstructorInitializers: BeforeComma
57+
BreakAfterJavaFieldAnnotations: false
58+
BreakStringLiterals: false
59+
ColumnLimit: 99
60+
CommentPragmas: '^ IWYU pragma:'
61+
QualifierAlignment: Leave
62+
CompactNamespaces: false
63+
ConstructorInitializerIndentWidth: 4
64+
ContinuationIndentWidth: 4
65+
Cpp11BracedListStyle: true
66+
DeriveLineEnding: true
67+
DerivePointerAlignment: false
68+
DisableFormat: false
69+
EmptyLineAfterAccessModifier: Never
70+
EmptyLineBeforeAccessModifier: LogicalBlock
71+
ExperimentalAutoDetectBinPacking: false
72+
PackConstructorInitializers: BinPack
73+
BasedOnStyle: ''
74+
ConstructorInitializerAllOnOneLineOrOnePerLine: false
75+
AllowAllConstructorInitializersOnNextLine: true
76+
FixNamespaceComments: false
77+
ForEachMacros:
78+
- foreach
79+
- Q_FOREACH
80+
- BOOST_FOREACH
81+
IfMacros:
82+
- KJ_IF_MAYBE
83+
IncludeBlocks: Preserve
84+
IncludeCategories:
85+
- Regex: '.*'
86+
Priority: 1
87+
SortPriority: 0
88+
CaseSensitive: false
89+
- Regex: '^(<|"(gtest|gmock|isl|json)/)'
90+
Priority: 3
91+
SortPriority: 0
92+
CaseSensitive: false
93+
- Regex: '.*'
94+
Priority: 1
95+
SortPriority: 0
96+
CaseSensitive: false
97+
IncludeIsMainRegex: '(Test)?$'
98+
IncludeIsMainSourceRegex: ''
99+
IndentAccessModifiers: false
100+
IndentCaseLabels: false
101+
IndentCaseBlocks: false
102+
IndentGotoLabels: true
103+
IndentPPDirectives: None
104+
IndentExternBlock: AfterExternBlock
105+
IndentRequires: false
106+
IndentWidth: 4
107+
IndentWrappedFunctionNames: true
108+
InsertTrailingCommas: None
109+
JavaScriptQuotes: Leave
110+
JavaScriptWrapImports: true
111+
KeepEmptyLinesAtTheStartOfBlocks: false
112+
LambdaBodyIndentation: Signature
113+
MacroBlockBegin: ''
114+
MacroBlockEnd: ''
115+
MaxEmptyLinesToKeep: 1
116+
NamespaceIndentation: None
117+
ObjCBinPackProtocolList: Auto
118+
ObjCBlockIndentWidth: 4
119+
ObjCBreakBeforeNestedBlockParam: true
120+
ObjCSpaceAfterProperty: true
121+
ObjCSpaceBeforeProtocolList: true
122+
PenaltyBreakAssignment: 10
123+
PenaltyBreakBeforeFirstCallParameter: 30
124+
PenaltyBreakComment: 10
125+
PenaltyBreakFirstLessLess: 0
126+
PenaltyBreakOpenParenthesis: 0
127+
PenaltyBreakString: 10
128+
PenaltyBreakTemplateDeclaration: 10
129+
PenaltyExcessCharacter: 100
130+
PenaltyReturnTypeOnItsOwnLine: 60
131+
PenaltyIndentedWhitespace: 0
132+
PointerAlignment: Left
133+
PPIndentWidth: -1
134+
ReferenceAlignment: Pointer
135+
ReflowComments: false
136+
RemoveBracesLLVM: false
137+
SeparateDefinitionBlocks: Leave
138+
ShortNamespaceLines: 1
139+
SortIncludes: Never
140+
SortJavaStaticImport: Before
141+
SortUsingDeclarations: false
142+
SpaceAfterCStyleCast: false
143+
SpaceAfterLogicalNot: false
144+
SpaceAfterTemplateKeyword: true
145+
SpaceBeforeAssignmentOperators: true
146+
SpaceBeforeCaseColon: false
147+
SpaceBeforeCpp11BracedList: false
148+
SpaceBeforeCtorInitializerColon: true
149+
SpaceBeforeInheritanceColon: true
150+
SpaceBeforeParens: Never
151+
SpaceBeforeParensOptions:
152+
AfterControlStatements: false
153+
AfterForeachMacros: false
154+
AfterFunctionDefinitionName: false
155+
AfterFunctionDeclarationName: false
156+
AfterIfMacros: false
157+
AfterOverloadedOperator: false
158+
BeforeNonEmptyParentheses: false
159+
SpaceAroundPointerQualifiers: Default
160+
SpaceBeforeRangeBasedForLoopColon: true
161+
SpaceInEmptyBlock: false
162+
SpaceInEmptyParentheses: false
163+
SpacesBeforeTrailingComments: 1
164+
SpacesInAngles: Never
165+
SpacesInConditionalStatement: false
166+
SpacesInContainerLiterals: false
167+
SpacesInCStyleCastParentheses: false
168+
SpacesInLineCommentPrefix:
169+
Minimum: 1
170+
Maximum: -1
171+
SpacesInParentheses: false
172+
SpacesInSquareBrackets: false
173+
SpaceBeforeSquareBrackets: false
174+
BitFieldColonSpacing: Both
175+
Standard: c++03
176+
StatementAttributeLikeMacros:
177+
- Q_EMIT
178+
StatementMacros:
179+
- Q_UNUSED
180+
- QT_REQUIRE_VERSION
181+
TabWidth: 4
182+
UseCRLF: false
183+
UseTab: Never
184+
WhitespaceSensitiveMacros:
185+
- STRINGIZE
186+
- PP_STRINGIZE
187+
- BOOST_PP_STRINGIZE
188+
- NS_SWIFT_NAME
189+
- CF_SWIFT_NAME
190+
...
191+

application.fam

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
App(
2+
appid="totp",
3+
name="Authenticator",
4+
apptype=FlipperAppType.EXTERNAL,
5+
entry_point="totp_app",
6+
cdefines=["APP_TOTP"],
7+
requires=[
8+
"gui",
9+
"cli",
10+
"dialogs",
11+
"storage"
12+
],
13+
provides=["totp_start"],
14+
stack_size=2 * 1024,
15+
order=20,
16+
fap_category="Misc",
17+
fap_icon="totp_10px.png",
18+
)
19+
20+
App(
21+
appid="totp_start",
22+
apptype=FlipperAppType.STARTUP,
23+
entry_point="totp_on_system_start",
24+
requires=["totp"],
25+
order=30,
26+
)

lib/base32/base32.c

+95
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
// Base32 implementation
2+
//
3+
// Copyright 2010 Google Inc.
4+
// Author: Markus Gutschke
5+
//
6+
// Licensed under the Apache License, Version 2.0 (the "License");
7+
// you may not use this file except in compliance with the License.
8+
// You may obtain a copy of the License at
9+
//
10+
// http://www.apache.org/licenses/LICENSE-2.0
11+
//
12+
// Unless required by applicable law or agreed to in writing, software
13+
// distributed under the License is distributed on an "AS IS" BASIS,
14+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
// See the License for the specific language governing permissions and
16+
// limitations under the License.
17+
18+
#include <string.h>
19+
20+
#include "base32.h"
21+
22+
int base32_decode(const uint8_t *encoded, uint8_t *result, int bufSize) {
23+
int buffer = 0;
24+
int bitsLeft = 0;
25+
int count = 0;
26+
for (const uint8_t *ptr = encoded; count < bufSize && *ptr; ++ptr) {
27+
uint8_t ch = *ptr;
28+
if (ch == ' ' || ch == '\t' || ch == '\r' || ch == '\n' || ch == '-') {
29+
continue;
30+
}
31+
buffer <<= 5;
32+
33+
// Deal with commonly mistyped characters
34+
if (ch == '0') {
35+
ch = 'O';
36+
} else if (ch == '1') {
37+
ch = 'L';
38+
} else if (ch == '8') {
39+
ch = 'B';
40+
}
41+
42+
// Look up one base32 digit
43+
if ((ch >= 'A' && ch <= 'Z') || (ch >= 'a' && ch <= 'z')) {
44+
ch = (ch & 0x1F) - 1;
45+
} else if (ch >= '2' && ch <= '7') {
46+
ch -= '2' - 26;
47+
} else {
48+
return -1;
49+
}
50+
51+
buffer |= ch;
52+
bitsLeft += 5;
53+
if (bitsLeft >= 8) {
54+
result[count++] = buffer >> (bitsLeft - 8);
55+
bitsLeft -= 8;
56+
}
57+
}
58+
if (count < bufSize) {
59+
result[count] = '\000';
60+
}
61+
return count;
62+
}
63+
64+
int base32_encode(const uint8_t *data, int length, uint8_t *result,
65+
int bufSize) {
66+
if (length < 0 || length > (1 << 28)) {
67+
return -1;
68+
}
69+
int count = 0;
70+
if (length > 0) {
71+
int buffer = data[0];
72+
int next = 1;
73+
int bitsLeft = 8;
74+
while (count < bufSize && (bitsLeft > 0 || next < length)) {
75+
if (bitsLeft < 5) {
76+
if (next < length) {
77+
buffer <<= 8;
78+
buffer |= data[next++] & 0xFF;
79+
bitsLeft += 8;
80+
} else {
81+
int pad = 5 - bitsLeft;
82+
buffer <<= pad;
83+
bitsLeft += pad;
84+
}
85+
}
86+
int index = 0x1F & (buffer >> (bitsLeft - 5));
87+
bitsLeft -= 5;
88+
result[count++] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"[index];
89+
}
90+
}
91+
if (count < bufSize) {
92+
result[count] = '\000';
93+
}
94+
return count;
95+
}

lib/base32/base32.h

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// Base32 implementation
2+
//
3+
// Copyright 2010 Google Inc.
4+
// Author: Markus Gutschke
5+
//
6+
// Licensed under the Apache License, Version 2.0 (the "License");
7+
// you may not use this file except in compliance with the License.
8+
// You may obtain a copy of the License at
9+
//
10+
// http://www.apache.org/licenses/LICENSE-2.0
11+
//
12+
// Unless required by applicable law or agreed to in writing, software
13+
// distributed under the License is distributed on an "AS IS" BASIS,
14+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
// See the License for the specific language governing permissions and
16+
// limitations under the License.
17+
//
18+
// Encode and decode from base32 encoding using the following alphabet:
19+
// ABCDEFGHIJKLMNOPQRSTUVWXYZ234567
20+
// This alphabet is documented in RFC 4648/3548
21+
//
22+
// We allow white-space and hyphens, but all other characters are considered
23+
// invalid.
24+
//
25+
// All functions return the number of output bytes or -1 on error. If the
26+
// output buffer is too small, the result will silently be truncated.
27+
28+
#ifndef _BASE32_H_
29+
#define _BASE32_H_
30+
31+
#include <stdint.h>
32+
33+
int base32_decode(const uint8_t *encoded, uint8_t *result, int bufSize)
34+
__attribute__((visibility("hidden")));
35+
int base32_encode(const uint8_t *data, int length, uint8_t *result,
36+
int bufSize)
37+
__attribute__((visibility("hidden")));
38+
39+
#endif /* _BASE32_H_ */

0 commit comments

Comments
 (0)