Skip to content

Commit

Permalink
Update documentations
Browse files Browse the repository at this point in the history
  • Loading branch information
Thai Dinh Le authored and Thai Dinh Le committed Jun 1, 2021
1 parent ed8ae71 commit 552b0ce
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 58 deletions.
13 changes: 2 additions & 11 deletions example/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,6 @@

Demonstrates how to use the adhoc_plugin plugin.

## Getting Started
## Music App Sharing

This project is a starting point for a Flutter application.

A few resources to get you started if this is your first Flutter project:

- [Lab: Write your first Flutter app](https://flutter.dev/docs/get-started/codelab)
- [Cookbook: Useful Flutter samples](https://flutter.dev/docs/cookbook)

For help getting started with Flutter, view our
[online documentation](https://flutter.dev/docs), which offers tutorials,
samples, guidance on mobile development, and a full API reference.
This example shows how the ad hoc library is used to implement a music sharing application.
2 changes: 1 addition & 1 deletion example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ packages:
name: path_provider
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.1"
version: "2.0.2"
path_provider_linux:
dependency: transitive
description:
Expand Down
2 changes: 1 addition & 1 deletion example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ dependencies:
analyzer_plugin: ^0.6.0
cupertino_icons: ^1.0.3
file_picker: ^3.0.1
path_provider: ^2.0.1
path_provider: ^2.0.2

dev_dependencies:
flutter_test:
Expand Down
10 changes: 5 additions & 5 deletions lib/src/network/aodv/rreq.dart
Original file line number Diff line number Diff line change
Expand Up @@ -50,19 +50,19 @@ class RREQ extends AodvMessage {

/*------------------------------Getters & Setters-----------------------------*/

/// Returns the hop count of the RREQ message.
/// Hop count of the RREQ message.
int get hopCount => _hopCount = _hopCount + 1;

/// Returns the broadcast ID of the RREQ message.
/// Broadcast ID of the RREQ message.
int get rreqId => _rreqId;

/// Returns the destination address of the RREQ message.
/// Destination address of the RREQ message.
String get dstAddr => _dstAddr;

/// Returns the source hop count of the RREQ message.
/// Source hop count of the RREQ message.
int get srcSeqNum => _srcSeqNum;

/// Returns the source address of the RREQ message.
/// Source address of the RREQ message.
String get srcAddr => _srcAddr;

/*-------------------------------Public methods-------------------------------*/
Expand Down
3 changes: 1 addition & 2 deletions lib/src/presentation/constants.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ const SECRET_DATA = 1; // Encrypted data tag for cryptographic tasks
// Constants for the certificate management
const ENCRYPTED_DATA = 300; // Data encrypted received or to send
const UNENCRYPTED_DATA = 301; // Data unencrypted received or to send
const CERT_XCHG_REQ = 302; // Certificate exchange request
const CERT_XCHG_REP = 303; // Certificate exchange reply
const CERT_EXCHANGE = 302; // Certificate exchange request
const CERT_REQ = 304; // Request certificate
const CERT_REP = 305; // Reply to certificate request
const CERT_REVOCATION = 306; // Certificate revocation notification
Expand Down
23 changes: 2 additions & 21 deletions lib/src/presentation/presentation_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ class PresentationManager {

// Generate a message for certificate exchange process
SecureData msg = SecureData(
CERT_XCHG_REQ,
CERT_EXCHANGE,
[_engine.publicKey.modulus.toString(),
_engine.publicKey.exponent.toString()]
);
Expand Down Expand Up @@ -318,26 +318,7 @@ class PresentationManager {
_controller.add(AdHocEvent(DATA_RECEIVED, [sender, pdu.payload]));
break;

case CERT_XCHG_REQ:
List<String> _pdu = (pdu.payload as List<dynamic>).cast<String>();
// Issue a certificate
_issueCertificate(
senderLabel,
RSAPublicKey(BigInt.parse(_pdu.first), BigInt.parse(_pdu.last))
);

// Construct a SecureData message for certificate exchange process
SecureData data = SecureData(
CERT_XCHG_REP,
[_engine.publicKey.modulus.toString(),
_engine.publicKey.exponent.toString()]
);

// Send this node's public key the directly trusted neighbor
_aodvManager.sendMessageTo(senderLabel, data.toJson());
break;

case CERT_XCHG_REP:
case CERT_EXCHANGE:
List<String> _pdu = (pdu.payload as List<dynamic>).cast<String>();
// Issue a certificate
_issueCertificate(
Expand Down
10 changes: 10 additions & 0 deletions lib/src/presentation/secure_data.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,28 @@ import 'package:json_annotation/json_annotation.dart';
part 'secure_data.g.dart';


/// Class encapsulating the presentation data.
@JsonSerializable()
class SecureData {
Object? payload;

late int type;

/// Creates an [SecureData] object.
///
/// The type of message is specified by [type], which determines the
/// structure of [payload].
SecureData(this.type, this.payload);

/// Creates a [SecureData] object from a JSON representation.
///
/// Factory constructor that creates a [SecureData] based on the information
/// given by [json].
factory SecureData.fromJson(Map<String, dynamic> json)
=> _$SecureDataFromJson(json);

/*-------------------------------Public methods-------------------------------*/

/// Returns the JSON representation as a [Map] of this [SecureData] instance.
Map<String, dynamic> toJson() => _$SecureDataToJson(this);
}
5 changes: 4 additions & 1 deletion lib/src/presentation/secure_group_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ class SecureGroupController {
///
/// The message payload is set to [data] and is encrypted using the group key.
void sendMessageToGroup(Object? data) async {
Future<List> encrypted = _engine.encrypt(
List encrypted = await _engine.encrypt(
Utf8Encoder().convert(JsonCodec().encode(data)),
sharedKey: _groupKey!,
);
Expand Down Expand Up @@ -453,6 +453,9 @@ class SecureGroupController {
String joiningMember = payload[0] as String;
_memberLabel.add(joiningMember);

if (_memberLabel.contains(joiningMember))
return;

// Compute hash of the group key and send it along public Diffie-Hellman
// shares of all group members to the joining member.
BigInt groupKeyHash = await _computeGroupKeyHash();
Expand Down
16 changes: 0 additions & 16 deletions test/presentation/presentation_manager_test.dart

This file was deleted.

0 comments on commit 552b0ce

Please sign in to comment.