Skip to content

BLE: Security Manager #6188

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 346 commits into from
Mar 2, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
346 commits
Select commit Hold shift + click to select a range
8c1dd2f
Nordic BLE: SM pal function draft (legacy pairing)
pan- Jan 17, 2018
074597c
Nordic BLE: Draft SM event handler.
pan- Jan 17, 2018
ffb59ee
CORDIO BLE: Add PAL SM event handling (draft).
pan- Jan 16, 2018
527a316
BLE - Nordic: Add Skeleton for the security manager
pan- Jan 17, 2018
5277f5a
BLE: Fix signature of get_secure_connections_support in implementations.
pan- Jan 17, 2018
7e37cc7
Nordic BLE: SM pal function draft (legacy pairing)
pan- Jan 17, 2018
743e57f
Nordic BLE: Draft SM event handler.
pan- Jan 17, 2018
39141fa
Merge branch 'palsm-cordio-implementation' of https://github.com/pan-…
pan- Jan 17, 2018
2f04aec
shared types in common header, connected up the events in handlers
paul-szczepanek-arm Jan 17, 2018
b00b746
removed old type
paul-szczepanek-arm Jan 17, 2018
8db6427
use common io caps type
paul-szczepanek-arm Jan 17, 2018
25107b1
todo
paul-szczepanek-arm Jan 17, 2018
5a056a1
Merge pull request #7 from pan-/palsm-cordio-implementation
paul-szczepanek-arm Jan 18, 2018
01cdceb
key distribution now a class
paul-szczepanek-arm Jan 18, 2018
73e5f2d
removed old events that are now only in legacy handling
paul-szczepanek-arm Jan 18, 2018
dee4777
updated implementations with new classes for auth and distribution masks
paul-szczepanek-arm Jan 18, 2018
779d6eb
updated old key_ditribution type and fixed refs to pointers
paul-szczepanek-arm Jan 18, 2018
3f26435
pariring typo
paul-szczepanek-arm Jan 18, 2018
b63930f
fixed refs to arrays
paul-szczepanek-arm Jan 18, 2018
b88a270
fixed the pointers to pointers
paul-szczepanek-arm Jan 18, 2018
82c0847
missed one pointer to pointer
paul-szczepanek-arm Jan 18, 2018
021a1fd
io caps and key size now stored by stack, secured cahgned to encrypte…
paul-szczepanek-arm Jan 18, 2018
9c1444f
dropped redundant passkey num class
paul-szczepanek-arm Jan 18, 2018
2fe405a
propagated changes from pal to api and generic
paul-szczepanek-arm Jan 18, 2018
081b99e
link security reading from db to determine stats
paul-szczepanek-arm Jan 18, 2018
ab056aa
set io caps, removed redundant params from pairing request
paul-szczepanek-arm Jan 19, 2018
b60a464
constness and refs fixes
paul-szczepanek-arm Jan 19, 2018
c3b434b
fixed pal name of oob request
paul-szczepanek-arm Jan 19, 2018
8b36d5e
fixed non-matching types
paul-szczepanek-arm Jan 19, 2018
44a366d
BLE SM: Fix compilation errors
pan- Jan 19, 2018
5478855
Merge pull request #8 from pan-/palsm-orig
paul-szczepanek-arm Jan 19, 2018
9e3797c
timeout pal funcs combined into single result on api side
paul-szczepanek-arm Jan 19, 2018
5fcf2a6
Merge branch 'palsm' of https://github.com/paul-szczepanek-arm/mbed-o…
paul-szczepanek-arm Jan 19, 2018
4fb9593
removed todo
paul-szczepanek-arm Jan 19, 2018
888a050
BLE SM: Slight API adjustements and docs
pan- Jan 19, 2018
cc7b2ba
Merge pull request #9 from pan-/palsm-orig
paul-szczepanek-arm Jan 19, 2018
49e1fc3
moving pairing to its own group to match the other layers
paul-szczepanek-arm Jan 19, 2018
4fcb304
BLE SM: Fix rand end ediv length
pan- Jan 19, 2018
818ec8c
BLE SM: Align CordioPalSecurityManager with PalSecurityManager and fi…
pan- Jan 19, 2018
9082065
Merge pull request #10 from pan-/palsm-orig
paul-szczepanek-arm Jan 19, 2018
ebe2439
move deprecated funcs down, add replacement for encryption status
paul-szczepanek-arm Jan 19, 2018
3074d12
security mode split into encryption and signing key
paul-szczepanek-arm Jan 19, 2018
9fda555
missing conn handle
paul-szczepanek-arm Jan 19, 2018
e100f7c
returning csrk key, init distribution list
paul-szczepanek-arm Jan 19, 2018
cb66098
get rid of all the virtual warnings and fix enum types
paul-szczepanek-arm Jan 19, 2018
0367ceb
vincent style wrapping
paul-szczepanek-arm Jan 19, 2018
ad8dd5f
fix wrap
paul-szczepanek-arm Jan 19, 2018
f18af9f
retrieving signing key
paul-szczepanek-arm Jan 19, 2018
467b36e
get link security no longer needed in generic
paul-szczepanek-arm Jan 19, 2018
a849f7f
BLE Cordio: Enable handling of security.
pan- Jan 19, 2018
7b16999
BLE Cordio: partial implementation of set ltk.
pan- Jan 19, 2018
7f90c7c
signing enabling
paul-szczepanek-arm Jan 21, 2018
b20a49f
only one key distribution settings
paul-szczepanek-arm Jan 21, 2018
4820d64
moved signing to matching positin in file
paul-szczepanek-arm Jan 21, 2018
e2a4c08
set link security and set link ecryption added
paul-szczepanek-arm Jan 21, 2018
0ef6740
line wrap
paul-szczepanek-arm Jan 21, 2018
9be7dbe
mitm quality added
paul-szczepanek-arm Jan 21, 2018
e301f7a
removed redundant checks
paul-szczepanek-arm Jan 21, 2018
d880f62
encryption needs ltk rand and ediv
paul-szczepanek-arm Jan 21, 2018
3300395
missing init, removed redeclaration
paul-szczepanek-arm Jan 22, 2018
d1c29fa
added slave security request
paul-szczepanek-arm Jan 22, 2018
5e0ed3d
pul events to retrieve local ltk edvi rand
paul-szczepanek-arm Jan 22, 2018
cba92fe
db changes to suport peer and local keys
paul-szczepanek-arm Jan 22, 2018
4c56d4c
returning ref to array for csrk
paul-szczepanek-arm Jan 22, 2018
533f6a4
restructure cases to avoid warnings
paul-szczepanek-arm Jan 22, 2018
1208dc7
readability
paul-szczepanek-arm Jan 22, 2018
2ae05ea
enabling signing
paul-szczepanek-arm Jan 22, 2018
69aac8a
const fix
paul-szczepanek-arm Jan 22, 2018
305975b
hint role reversal, set the correct ltk keys
paul-szczepanek-arm Jan 22, 2018
2d8451f
block legacy pairing when requested
paul-szczepanek-arm Jan 22, 2018
b4e85b3
moved db into its own file
paul-szczepanek-arm Jan 22, 2018
2b7db78
pairing through a single function to keep settings
paul-szczepanek-arm Jan 22, 2018
8b84b93
fix to apply defaults for pairing response
paul-szczepanek-arm Jan 22, 2018
10b5e64
slave request handling
paul-szczepanek-arm Jan 22, 2018
4aa7158
temporary code for use during verification before we integrate with gap
paul-szczepanek-arm Jan 23, 2018
f1044fe
internal function naming
paul-szczepanek-arm Jan 23, 2018
f635555
refresh not needed, done through requesting encryption on encrypted link
paul-szczepanek-arm Jan 23, 2018
bc1e809
keeping state of connection, storing mitm quality of keys
paul-szczepanek-arm Jan 23, 2018
56ea420
read mitm of the csrk key not pairing
paul-szczepanek-arm Jan 23, 2018
92965ba
removed redundant mitm field
paul-szczepanek-arm Jan 23, 2018
c476fce
correct naming for private members
paul-szczepanek-arm Jan 23, 2018
8ef3311
naive memory implementation for verification purposes
paul-szczepanek-arm Jan 23, 2018
38f8a5b
separate live state from stored state in entry
paul-szczepanek-arm Jan 23, 2018
1cc5312
octet type for keys
paul-szczepanek-arm Jan 24, 2018
724aef9
moved types to common header
paul-szczepanek-arm Jan 28, 2018
ed0722c
upgraded oob data to octet type
paul-szczepanek-arm Jan 28, 2018
647aa1e
split security manager into a header and moved types to common types
paul-szczepanek-arm Jan 29, 2018
f4d29bb
clear up private address resolution
paul-szczepanek-arm Jan 29, 2018
eb899bc
split identity away from meta data and csrk, moved privacy feature fr…
paul-szczepanek-arm Jan 29, 2018
d0c4186
moved fucntion impl to match position in header
paul-szczepanek-arm Jan 29, 2018
9786244
removed redundant const
paul-szczepanek-arm Jan 29, 2018
faf134a
move helper funcitons under their own heading
paul-szczepanek-arm Jan 29, 2018
9e79ba4
doxygen
paul-szczepanek-arm Jan 30, 2018
322ee90
doxygen fixes
paul-szczepanek-arm Jan 30, 2018
e686eec
missing implementation for whitelist from bond table and more doxygen
paul-szczepanek-arm Jan 30, 2018
2060ad5
we don't need two event handler since now the generic security manage…
paul-szczepanek-arm Jan 30, 2018
62502fe
more doxygen and naming consistency
paul-szczepanek-arm Jan 31, 2018
5498b79
doxygen, moved types to common
paul-szczepanek-arm Jan 31, 2018
714069b
deal with failed LTK retrieval, remove unused functionality, more dox…
paul-szczepanek-arm Jan 31, 2018
132b9e0
fix encryption call to accept 16 octets
paul-szczepanek-arm Jan 31, 2018
f53359f
doxygen
paul-szczepanek-arm Jan 31, 2018
32e91ac
removed idenitty list as resolution will be done insite the db asynch…
paul-szczepanek-arm Feb 1, 2018
9bc8c56
address types added, secure connectins oob added
paul-szczepanek-arm Feb 6, 2018
aba65d7
added doxygen
paul-szczepanek-arm Feb 6, 2018
7aa9ae7
fix typos
paul-szczepanek-arm Feb 6, 2018
3236ead
multiple ltks single irk and csrk
paul-szczepanek-arm Feb 6, 2018
1446142
ltk for secure connections
paul-szczepanek-arm Feb 6, 2018
b6be4df
doxygen
paul-szczepanek-arm Feb 6, 2018
8cc3665
added OOB to interface, moved address type to common
paul-szczepanek-arm Feb 6, 2018
4c56f89
removed redundancy in types
paul-szczepanek-arm Feb 6, 2018
20444c8
missing implementations
paul-szczepanek-arm Feb 7, 2018
1b6a84d
oob data propagated to pal
paul-szczepanek-arm Feb 7, 2018
b5b86b7
oob handling inside genric for secure connections
paul-szczepanek-arm Feb 8, 2018
0b15798
style and moved for clarity
paul-szczepanek-arm Feb 8, 2018
cba77ad
saving public keys
paul-szczepanek-arm Feb 8, 2018
d061c89
storing sc oob, checking for its presence
paul-szczepanek-arm Feb 8, 2018
56530d4
sc oob verification needs local random value
paul-szczepanek-arm Feb 8, 2018
0a54ca3
move pairing under its own heading to match other parts
paul-szczepanek-arm Feb 8, 2018
a2cff30
move oob to db, add cmac helper func
paul-szczepanek-arm Feb 8, 2018
0806584
oob presence set correctly for legacy pairing
paul-szczepanek-arm Feb 9, 2018
947c6ed
implement oob data store in db
paul-szczepanek-arm Feb 9, 2018
5647496
cmac using the tls implementation
paul-szczepanek-arm Feb 9, 2018
fe9b558
init random number on local device for OOB data
paul-szczepanek-arm Feb 9, 2018
769c97e
random data generation
paul-szczepanek-arm Feb 9, 2018
e0c308f
fix buffer not being moved in random number generation
paul-szczepanek-arm Feb 9, 2018
e7cf152
remobed todo, will be handled by db
paul-szczepanek-arm Feb 9, 2018
18062fc
GAP integration for connection and disconnection events
paul-szczepanek-arm Feb 9, 2018
e91ab46
doxygen added
paul-szczepanek-arm Feb 9, 2018
379c86d
Merge pull request #11 from pan-/palsm-orig
paul-szczepanek-arm Feb 9, 2018
68db4dd
avoiding compiler issues
paul-szczepanek-arm Feb 11, 2018
934d8f9
pointers changed to references for a consistent PAL
paul-szczepanek-arm Feb 11, 2018
c93e800
missing ref
paul-szczepanek-arm Feb 11, 2018
90c30c9
typo
paul-szczepanek-arm Feb 11, 2018
2c1fcc7
style
paul-szczepanek-arm Feb 12, 2018
581b575
removed duplicate event handler, removed redundant using statements
paul-szczepanek-arm Feb 12, 2018
35b4ae4
typos
paul-szczepanek-arm Feb 12, 2018
5504501
fixed all the compilation errors and recent pal changes
paul-szczepanek-arm Feb 13, 2018
d44af8c
don't handle event handler memory by the SM
paul-szczepanek-arm Feb 13, 2018
2f1e211
set entry state on connect
paul-szczepanek-arm Feb 13, 2018
863bdfb
BLE: Add unit test for the Generic GattClient.
pan- Feb 13, 2018
6529d67
BLE: Fix include prefixes.
pan- Feb 19, 2018
c767299
BLE tests: Mock pal::SecurityManager.
pan- Feb 19, 2018
15cfcba
BLE: Move security DB into PAL.
pan- Feb 19, 2018
9b12c6b
BLE: Add SecurityManager tests to the build script.
pan- Feb 19, 2018
d68fbbd
Merge pull request #15 from pan-/palsm-test
paul-szczepanek-arm Feb 19, 2018
d9156a2
connection monitor
paul-szczepanek-arm Feb 19, 2018
8cf7b3b
Merge branch 'palsm' of https://github.com/paul-szczepanek-arm/mbed-o…
paul-szczepanek-arm Feb 19, 2018
ecacbda
compiler errors fixed after the merge
paul-szczepanek-arm Feb 19, 2018
dd7bc50
Merge branch 'master' into palsm
paul-szczepanek-arm Feb 19, 2018
990e212
pull in cordio security manager into BLE
paul-szczepanek-arm Feb 19, 2018
396ca2c
removed redundant cast
paul-szczepanek-arm Feb 19, 2018
cc896f1
BLE: Add mock for the security db.
pan- Feb 19, 2018
8b957f5
plaform/sleep: Fix inclusion and inline declaration.
pan- Feb 19, 2018
bcea06f
BLE: Fix inclusion of mbed_error.h
pan- Feb 19, 2018
8b9e08e
BLE tests: Add stub for device.h .
pan- Feb 19, 2018
28f2f46
BLE: Hide event monitor inside pal.
pan- Feb 19, 2018
4ce0ed9
BLE: Remove dependency of GenericSecurityManager towards gap.
pan- Feb 19, 2018
c1d15b5
Merge pull request #16 from pan-/palsm-test
paul-szczepanek-arm Feb 19, 2018
c654192
fixed compiler errors for pal after its update
paul-szczepanek-arm Feb 20, 2018
e3d7f2b
BLE: Add address type in AdvertisementCallbackParams_t.
pan- Feb 21, 2018
c5be493
BLE: Add address type in AdvertisementCallbackParams_t.
pan- Feb 21, 2018
9c6f44d
BLE: Force stop scan before connection initiation.
pan- Feb 21, 2018
ad78b3e
BLE: Handle NULL parameters in Gap::connect.
pan- Feb 21, 2018
9e98a72
BLE: Move cordio default scan and connection params in global memory.
pan- Feb 21, 2018
6b0ba64
SM fixes to init and register the event handler correctly
paul-szczepanek-arm Feb 21, 2018
1da5d74
temporary key encryption mitm quality reflected
paul-szczepanek-arm Feb 22, 2018
1698c2d
BLE: Add missing encryption implementation in cordio pal SM.
pan- Feb 22, 2018
02f01f0
Merge branch 'palsm' of https://github.com/paul-szczepanek-arm/mbed-o…
paul-szczepanek-arm Feb 22, 2018
88d9342
Merge pull request #12 from paul-szczepanek-arm/palsm
paul-szczepanek-arm Feb 23, 2018
c8f7725
Merge https://github.com/ARMmbed/mbed-os
paul-szczepanek-arm Feb 23, 2018
2bb73fd
BLE: Cleanup includes of pal::ConnectionEventMonitor.
pan- Feb 19, 2018
7db6aeb
BLE: Add mock and stub for ConnectionEventMonitor.
pan- Feb 19, 2018
52910af
BLE: Add mock for SecurityManagerEventHandler.
pan- Feb 19, 2018
1ded0d7
BLE: Split security manager control block from the secure DB.
pan- Feb 23, 2018
11a809e
BLE: remove MorySecurityDb include from generic security manager.
pan- Feb 23, 2018
268655a
Merge pull request #17 from pan-/security-db-rework
paul-szczepanek-arm Feb 23, 2018
d586f7f
BLE: update SecurityDB comments.
pan- Feb 23, 2018
41ee797
Merge https://github.com/ARMmbed/mbed-os
paul-szczepanek-arm Feb 23, 2018
47e005e
BLE: Fix address report in Maxim port.
pan- Feb 23, 2018
1f4e2b1
BLE: Fix Gap::processAdvertisementReport documentation
pan- Feb 23, 2018
3554a63
BLE: Add default addressType to processAdvertisementReport
pan- Feb 26, 2018
b939721
BLE: Ensure passkey is not null before integer conversion
pan- Feb 27, 2018
7833d79
BLE: Fix security manager mocks
pan- Feb 27, 2018
47eea76
BLE: Test db entry open and close in the generic security manager.
pan- Feb 27, 2018
c9690c9
upate doxygen since passkey is no longer a pointer
paul-szczepanek-arm Feb 27, 2018
5510636
removed redundant type
paul-szczepanek-arm Feb 27, 2018
b0c7d72
variable name updated in the undefed cmac blocks
paul-szczepanek-arm Feb 27, 2018
5de1979
types renamed as per review requests
paul-szczepanek-arm Feb 27, 2018
8142cb5
redundant call removed
paul-szczepanek-arm Feb 27, 2018
4fd2963
removed redundant type
paul-szczepanek-arm Feb 27, 2018
4010bad
reanmed type as per review request
paul-szczepanek-arm Feb 27, 2018
361ae8c
BLE: fix references to oob_rand_t.
pan- Feb 27, 2018
62e9011
public key renaned (added coord), also contains missing commit for oo…
paul-szczepanek-arm Feb 27, 2018
0b0d614
Merge branch 'master' of https://github.com/paul-szczepanek-arm/mbed-…
pan- Feb 27, 2018
0f1fd58
removed MIC related functions and events from the user API
paul-szczepanek-arm Feb 27, 2018
957cee3
Merge branch 'master' of https://github.com/paul-szczepanek-arm/mbed-os
paul-szczepanek-arm Feb 27, 2018
928dbcf
BLE: Fix prefix of BLEProtocol::AddressType
pan- Feb 27, 2018
536f541
mic event no longer present in user api, removing call
paul-szczepanek-arm Feb 27, 2018
d264512
remove virtual as per review request
paul-szczepanek-arm Feb 27, 2018
fc01cff
removed using statements from header
paul-szczepanek-arm Feb 27, 2018
bf8204a
BLE: remove host testing from sm pr
pan- Feb 27, 2018
e568aa4
Merge branch 'master' of https://github.com/ARMmbed/mbed-os into pr-sm
pan- Feb 27, 2018
81126ad
BLE: remove draft of nordic pal security manager.
pan- Feb 27, 2018
e186985
addressing PR review: added documentation, moved code and renamed vars
paul-szczepanek-arm Feb 27, 2018
8e41de2
Merge branch 'master' of https://github.com/paul-szczepanek-arm/mbed-os
paul-szczepanek-arm Feb 27, 2018
96de1c2
header guards renamed
paul-szczepanek-arm Feb 27, 2018
975544f
link key distribution decision made in generic security manager
paul-szczepanek-arm Feb 27, 2018
abcc5db
fix setting default values which were overriding even when unset
paul-szczepanek-arm Feb 28, 2018
c52d324
pass in information about the mitm and sc quality of the ltk to the pal
paul-szczepanek-arm Feb 28, 2018
701c18b
missing documentation, removed privacy call from api
paul-szczepanek-arm Feb 28, 2018
d20c4ef
documentation overview for securitymanager
paul-szczepanek-arm Feb 28, 2018
f9a79be
fixed initiator distribution bug and setting LINK distribution field …
paul-szczepanek-arm Feb 28, 2018
766b876
BLE: Accept pairing request when the user authorization is not required.
pan- Mar 1, 2018
dbf4a8d
BLE: Implement CordioSM get_secure_connection_support.
pan- Mar 1, 2018
d050c4e
BLE: Fix CordioPalSM set_io_capability
pan- Mar 1, 2018
c00ae29
Cordio: Update stack binaries.
pan- Mar 1, 2018
cebc0f8
create encryption result event even when nothing changes
paul-szczepanek-arm Mar 1, 2018
179ad16
Merge branch 'master' of https://github.com/paul-szczepanek-arm/mbed-os
paul-szczepanek-arm Mar 1, 2018
d5b8439
removed redundant check
paul-szczepanek-arm Mar 1, 2018
bc11834
fix not setting encryption state in generic
paul-szczepanek-arm Mar 1, 2018
7e2f5ee
fix not setting the mitm performed state correctly
paul-szczepanek-arm Mar 1, 2018
e29ea95
BLE: Return error when security deascalation is requested.
pan- Mar 1, 2018
1170b31
BLE: Remove useless pal sm API
pan- Mar 1, 2018
cd7d9c5
Cordio pal SM: comment appropriately privacy related functions.
pan- Mar 1, 2018
a057e5c
BLE - Cordio PAL SM: Fix force secure connection.
pan- Mar 1, 2018
054b780
BLE - Cordio PAL SM: implement set_authentication_timeout
pan- Mar 1, 2018
4858388
BLE - Cordio PAL SM: comment get_authentication_timeout
pan- Mar 1, 2018
79db2af
BLE - Cordio PAL SM: Choose correct security level in set_ltk
pan- Mar 1, 2018
9043714
BLE - Cordio PAL SM: Select correct security level in enable_encryption
pan- Mar 1, 2018
ecc7118
BLE - Cordio PAL SM: Implement send_keypress_notification
pan- Mar 1, 2018
18c9399
BLE - Cordio PAL Sm: generate random passkey displayed.
pan- Mar 1, 2018
628ffea
BLE - Cordio PAL SM: Forward local keys
pan- Mar 1, 2018
da6ede3
BLE - Cordio PAL SM: Select correct on_ltk_request overload.
pan- Mar 1, 2018
56af3cb
CBLE - Cordio PAL SM: Implement slave security request notification
pan- Mar 1, 2018
36247b3
BLE - Cordio PAL SM: Implement Keypress notification
pan- Mar 1, 2018
e8f29f7
BLE - Cordio - PAL SM: refine comments and formating.
pan- Mar 1, 2018
00df64b
Fixed PasskeyAscii constructor
Mar 1, 2018
b89f9f2
added callback on encryption request even if lower and restructured f…
paul-szczepanek-arm Mar 1, 2018
0870b30
Merge branch 'master' of https://github.com/paul-szczepanek-arm/mbed-os
paul-szczepanek-arm Mar 1, 2018
392ee6e
removed get encryption key size from API
paul-szczepanek-arm Mar 1, 2018
03f79ee
BLE: Remove Nordic Pal SM draft.
pan- Mar 1, 2018
8e21b53
Merge branch 'master' of https://github.com/paul-szczepanek-arm/mbed-…
pan- Mar 1, 2018
f040569
BLE: Resolve issue with address type in advertising report.
pan- Mar 1, 2018
e706b41
removed redundant event for SC OOB request, fixed comments
paul-szczepanek-arm Mar 1, 2018
68f2561
no need to ask for encryption after pairing, fold deref under the nul…
paul-szczepanek-arm Mar 1, 2018
8347e76
Merge https://github.com/ARMmbed/mbed-os
paul-szczepanek-arm Mar 1, 2018
1f52e42
more detailed comment for confirmation request
paul-szczepanek-arm Mar 1, 2018
371f183
added one more sequence diagram
paul-szczepanek-arm Mar 1, 2018
ded1403
security manager overview doc fixes
paul-szczepanek-arm Mar 1, 2018
a3383c1
Addressed Vincent's comments
Mar 1, 2018
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
1 change: 1 addition & 0 deletions features/FEATURE_BLE/.mbedignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
tests/*
2 changes: 1 addition & 1 deletion features/FEATURE_BLE/ble/BLE.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#ifdef YOTTA_CFG_MBED_OS
#include "mbed-drivers/mbed_error.h"
#else
#include "mbed_error.h"
#include "platform/mbed_error.h"
#endif

#include "platform/mbed_toolchain.h"
Expand Down
268 changes: 265 additions & 3 deletions features/FEATURE_BLE/ble/BLETypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

#include <stddef.h>
#include <stdint.h>
#include <string.h>
#include "ble/SafeEnum.h"

/**
* @addtogroup ble
Expand Down Expand Up @@ -54,7 +56,7 @@ typedef uint16_t attribute_handle_t;
*/
struct attribute_handle_range_t {
/**
* Begining of the range.
* Beginning of the range.
*/
attribute_handle_t begin;

Expand Down Expand Up @@ -96,8 +98,8 @@ struct attribute_handle_range_t {
/**
* Construct an attribute_handle_range_t from its first and last attribute handle.
*
* @param begin Handle at the begining of the range.
* @param end Handle at the end of the range.
* @param[in] begin Handle at the beginning of the range.
* @param[in] end Handle at the end of the range.
*
* @return An instance of attribute_handle_range_t where
* attribute_handle_range_t::begin is equal to begin and
Expand All @@ -117,6 +119,266 @@ static inline attribute_handle_range_t attribute_handle_range(
return result;
}

/**
* Type that describes link's encryption state.
*/
struct link_encryption_t : SafeEnum<link_encryption_t, uint8_t> {
/** struct scoped enum wrapped by the class */
enum type {
NOT_ENCRYPTED, /**< The link is not secured. */
ENCRYPTION_IN_PROGRESS, /**< Link security is being established. */
ENCRYPTED, /**< The link is secure. */
ENCRYPTED_WITH_MITM /**< The link is secure and authenticated. */
};

/**
* Construct a new instance of link_encryption_t.
*/
link_encryption_t(type value) : SafeEnum<link_encryption_t, uint8_t>(value) { }
};

/**
* Type that describe a pairing failure.
*/
struct pairing_failure_t : SafeEnum<pairing_failure_t, uint8_t> {
/** struct scoped enum wrapped by the class */
enum type {
PASSKEY_ENTRY_FAILED = 0x01,
OOB_NOT_AVAILABLE = 0x02,
AUTHENTICATION_REQUIREMENTS = 0x03,
CONFIRM_VALUE_FAILED = 0x04,
PAIRING_NOT_SUPPORTED = 0x05,
ENCRYPTION_KEY_SIZE = 0x06,
COMMAND_NOT_SUPPORTED = 0x07,
UNSPECIFIED_REASON = 0x08,
REPEATED_ATTEMPTS = 0x09,
INVALID_PARAMETERS = 0x0A,
DHKEY_CHECK_FAILED = 0x0B,
NUMERIC_COMPARISON_FAILED = 0x0c,
BR_EDR_PAIRING_IN_PROGRESS = 0x0D,
CROSS_TRANSPORT_KEY_DERIVATION_OR_GENERATION_NOT_ALLOWED = 0x0E
};

/**
* Construct a new instance of pairing_failure_t.
*/
pairing_failure_t(type value) : SafeEnum<pairing_failure_t, uint8_t>(value) { }
};


/**
* Type that describe the IO capability of a device; it is used during Pairing
* Feature exchange.
*/
struct io_capability_t : SafeEnum<io_capability_t, uint8_t> {
enum type {
DISPLAY_ONLY = 0x00,
DISPLAY_YES_NO = 0x01,
KEYBOARD_ONLY = 0x02,
NO_INPUT_NO_OUTPUT = 0x03,
KEYBOARD_DISPLAY = 0x04
};

/**
* Construct a new instance of io_capability_t.
*/
io_capability_t(type value) : SafeEnum<io_capability_t, uint8_t>(value) { }
};

/**
* Passkey stored as a number.
*/
typedef uint32_t passkey_num_t;

/**
* Passkey stored as a string of digits.
*/
class PasskeyAscii {
public:
static const uint8_t PASSKEY_LEN = 6;
static const uint8_t NUMBER_OFFSET = '0';

/**
* Default to all zeroes
*/
PasskeyAscii() {
memset(ascii, NUMBER_OFFSET, PASSKEY_LEN);
}

/**
* Initialize a data from a string.
*
* @param[in] passkey value of the data.
*/
PasskeyAscii(const uint8_t* passkey) {
if (passkey) {
memcpy(ascii, passkey, PASSKEY_LEN);
} else {
memset(ascii, NUMBER_OFFSET, PASSKEY_LEN);
}
}

/**
* Initialize a data from a number.
*
* @param[in] passkey value of the data.
*/
PasskeyAscii(passkey_num_t passkey) {
for (int i = 5, m = 100000; i >= 0; --i, m /= 10) {
uint32_t result = passkey / m;
ascii[i] = NUMBER_OFFSET + result;
passkey -= result * m;
}
}

/**
* Cast to number.
*/
operator passkey_num_t() {
return to_num(ascii);
}

/**
* Convert ASCII string of digits into a number.
* @param[in] ascii ASCII string of 6 digits stored as ASCII characters
* @return Passkey as a number.
*/
static uint32_t to_num(const uint8_t *ascii) {
uint32_t passkey = 0;
for (size_t i = 0, m = 1; i < PASSKEY_LEN; ++i, m *= 10) {
passkey += (ascii[i] - NUMBER_OFFSET) * m;
}
return passkey;
}

/**
* Return the pointer to the buffer holding the string.
*/
uint8_t* value() {
return ascii;
}
private:
uint8_t ascii[PASSKEY_LEN];
};

template <size_t array_size>
struct byte_array_t {
/**
* Default to all zeroes
*/
byte_array_t() {
memset(_value, 0x00, sizeof(_value));
}

/**
* Initialize a data from an array of bytes.
*
* @param[in] input_value value of the data.
*/
byte_array_t(const uint8_t *input_value) {
memcpy(_value, input_value, sizeof(_value));
}

/**
* Initialize a data from an buffer of bytes.
*
* @param[in] input_value pointer to buffer.
* @param[in] size buffer size
*/
byte_array_t(const uint8_t* input_value, size_t size) {
memcpy(_value, input_value, size);
}

/**
* Equal operator between two octet types.
*/
friend bool operator==(const byte_array_t& lhs, const byte_array_t& rhs) {
return memcmp(lhs._value, rhs._value, sizeof(lhs._value)) == 0;
}

/**
* Non equal operator between two octet types.
*/
friend bool operator!=(const byte_array_t& lhs, const byte_array_t& rhs) {
return !(lhs == rhs);
}

/**
* Subscript operator to access data content
*/
uint8_t& operator[](uint8_t i) {
return _value[i];
}

/**
* Return the pointer to the buffer holding data.
*/
const uint8_t* data() const {
return _value;
}

/**
* Return the pointer to the buffer holding data.
*/
uint8_t* buffer() {
return _value;
}

/**
* Size in byte of a data.
*/
static size_t size() {
return array_size;
}

protected:
uint8_t _value[array_size];
};

/** 128 bit keys used by paired devices */
typedef byte_array_t<16> irk_t;
typedef byte_array_t<16> csrk_t;
typedef byte_array_t<16> ltk_t;

/** Used to identify LTK for legacy pairing connections */
typedef byte_array_t<2> ediv_t;
typedef byte_array_t<8> rand_t;

/** Out of band data exchanged during pairing */
typedef byte_array_t<16> oob_tk_t; /**< legacy pairing TK */
typedef byte_array_t<16> oob_lesc_value_t; /**< secure connections oob random 128 value */
typedef byte_array_t<16> oob_confirm_t; /**< secure connections oob confirmation value */

/** data to be encrypted */
typedef byte_array_t<16> encryption_block_t;

/** public key coordinate, two of which define the public key */
typedef byte_array_t<32> public_key_coord_t;

/** Diffie-Hellman key */
typedef byte_array_t<32> dhkey_t;

/**
* MAC address data type.
*/
struct address_t : public byte_array_t<6> {
/**
* Create an invalid mac address, equal to FF:FF:FF:FF:FF:FF
*/
address_t() {
memset(_value, 0xFF, sizeof(_value));
}

/**
* Initialize a data from an array of bytes.
*
* @param[in] input_value value of the data.
*/
address_t(const uint8_t *input_value) {
memcpy(_value, input_value, sizeof(_value));
}
};

} // namespace ble

/**
Expand Down
17 changes: 15 additions & 2 deletions features/FEATURE_BLE/ble/Gap.h
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ class GapAdvertisingData;
* // Initiate the connection procedure
* gap.connect(
* packet->peerAddr,
* BLEProtocol::RANDOM_STATIC,
* packet->addressType,
* &connection_parameters,
* &scanning_params
* );
Expand Down Expand Up @@ -608,6 +608,11 @@ class Gap {
* Pointer to the advertisement packet's data.
*/
const uint8_t *advertisingData;

/**
* Type of the address received
*/
AddressType_t addressType;
};

/**
Expand Down Expand Up @@ -2304,6 +2309,7 @@ class Gap {
ownAddr,
connectionParams
);

connectionCallChain.call(&callbackParams);
}

Expand Down Expand Up @@ -2342,22 +2348,29 @@ class Gap {
* @param[in] type Advertising type of the packet.
* @param[in] advertisingDataLen Length of the advertisement data received.
* @param[in] advertisingData Pointer to the advertisement packet's data.
* @param[in] addressType Type of the address of the peer that has emitted the packet.
*/
void processAdvertisementReport(
const BLEProtocol::AddressBytes_t peerAddr,
int8_t rssi,
bool isScanResponse,
GapAdvertisingParams::AdvertisingType_t type,
uint8_t advertisingDataLen,
const uint8_t *advertisingData
const uint8_t *advertisingData,
BLEProtocol::AddressType_t addressType = BLEProtocol::AddressType::RANDOM_STATIC
) {
// FIXME: remove default parameter for addressType when ST shield is merged;
// this has been added to mitigate the lack of dependency management in
// testing jobs ....

AdvertisementCallbackParams_t params;
memcpy(params.peerAddr, peerAddr, ADDR_LEN);
params.rssi = rssi;
params.isScanResponse = isScanResponse;
params.type = type;
params.advertisingDataLen = advertisingDataLen;
params.advertisingData = advertisingData;
params.addressType = addressType;
onAdvertisementReport.call(&params);
}

Expand Down
Loading