Merge branch 'main' of https://github.com/hackku21/loc-chain-app into bluetooth

This commit is contained in:
Thomas Atkins 2021-04-10 13:48:50 -05:00
commit 9416b1188e
11 changed files with 260 additions and 72 deletions

View File

@ -1 +1,2 @@
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"
#include "Generated.xcconfig"

View File

@ -1 +1,2 @@
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"
#include "Generated.xcconfig"

41
loc_chain_app/ios/Podfile Normal file
View File

@ -0,0 +1,41 @@
# Uncomment this line to define a global platform for your project
# platform :ios, '9.0'
# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
project 'Runner', {
'Debug' => :debug,
'Profile' => :release,
'Release' => :release,
}
def flutter_root
generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__)
unless File.exist?(generated_xcode_build_settings_path)
raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first"
end
File.foreach(generated_xcode_build_settings_path) do |line|
matches = line.match(/FLUTTER_ROOT\=(.*)/)
return matches[1].strip if matches
end
raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get"
end
require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)
flutter_ios_podfile_setup
target 'Runner' do
use_frameworks!
use_modular_headers!
flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
end
post_install do |installer|
installer.pods_project.targets.each do |target|
flutter_additional_ios_build_settings(target)
end
end

View File

@ -0,0 +1,28 @@
PODS:
- fast_rsa (0.6.0):
- Flutter
- Flutter (1.0.0)
- path_provider (0.0.1):
- Flutter
DEPENDENCIES:
- fast_rsa (from `.symlinks/plugins/fast_rsa/ios`)
- Flutter (from `Flutter`)
- path_provider (from `.symlinks/plugins/path_provider/ios`)
EXTERNAL SOURCES:
fast_rsa:
:path: ".symlinks/plugins/fast_rsa/ios"
Flutter:
:path: Flutter
path_provider:
:path: ".symlinks/plugins/path_provider/ios"
SPEC CHECKSUMS:
fast_rsa: 348fa9c4afd02ab8659480e679f647f454acc80e
Flutter: 434fef37c0980e73bb6479ef766c45957d4b510c
path_provider: abfe2b5c733d04e238b0d8691db0cfd63a27a93c
PODFILE CHECKSUM: aafe91acc616949ddb318b77800a7f51bffa2a4c
COCOAPODS: 1.10.1

View File

@ -13,6 +13,7 @@
97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; };
97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; };
97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; };
E1C832068AB674471A23DFC7 /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2C427E90E3BB69D6B911A804 /* Pods_Runner.framework */; };
/* End PBXBuildFile section */
/* Begin PBXCopyFilesBuildPhase section */
@ -31,10 +32,14 @@
/* Begin PBXFileReference section */
1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = "<group>"; };
1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = "<group>"; };
2C427E90E3BB69D6B911A804 /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; };
31DACBD0B66191129EC4BA7F /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = "<group>"; };
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = "<group>"; };
65E120A3551B34655C1793C5 /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = "<group>"; };
74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = "<group>"; };
74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = "<group>"; };
8F26C49D78C6505C4C9F3FDA /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = "<group>"; };
9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = "<group>"; };
9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = "<group>"; };
97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; };
@ -49,12 +54,24 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
E1C832068AB674471A23DFC7 /* Pods_Runner.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
69EB72FA53A9891457653AAB /* Pods */ = {
isa = PBXGroup;
children = (
8F26C49D78C6505C4C9F3FDA /* Pods-Runner.debug.xcconfig */,
65E120A3551B34655C1793C5 /* Pods-Runner.release.xcconfig */,
31DACBD0B66191129EC4BA7F /* Pods-Runner.profile.xcconfig */,
);
name = Pods;
path = Pods;
sourceTree = "<group>";
};
9740EEB11CF90186004384FC /* Flutter */ = {
isa = PBXGroup;
children = (
@ -72,6 +89,8 @@
9740EEB11CF90186004384FC /* Flutter */,
97C146F01CF9000F007C117D /* Runner */,
97C146EF1CF9000F007C117D /* Products */,
69EB72FA53A9891457653AAB /* Pods */,
FCDA85F51884D241BBF6E2C7 /* Frameworks */,
);
sourceTree = "<group>";
};
@ -98,6 +117,14 @@
path = Runner;
sourceTree = "<group>";
};
FCDA85F51884D241BBF6E2C7 /* Frameworks */ = {
isa = PBXGroup;
children = (
2C427E90E3BB69D6B911A804 /* Pods_Runner.framework */,
);
name = Frameworks;
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
@ -105,12 +132,14 @@
isa = PBXNativeTarget;
buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */;
buildPhases = (
26B33161B5A1B29F50036AAB /* [CP] Check Pods Manifest.lock */,
9740EEB61CF901F6004384FC /* Run Script */,
97C146EA1CF9000F007C117D /* Sources */,
97C146EB1CF9000F007C117D /* Frameworks */,
97C146EC1CF9000F007C117D /* Resources */,
9705A1C41CF9048500538489 /* Embed Frameworks */,
3B06AD1E1E4923F5004D2608 /* Thin Binary */,
10B41FA962D6462BEAB7F8B2 /* [CP] Embed Pods Frameworks */,
);
buildRules = (
);
@ -169,6 +198,45 @@
/* End PBXResourcesBuildPhase section */
/* Begin PBXShellScriptBuildPhase section */
10B41FA962D6462BEAB7F8B2 /* [CP] Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-input-files.xcfilelist",
);
name = "[CP] Embed Pods Frameworks";
outputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-output-files.xcfilelist",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n";
showEnvVarsInLog = 0;
};
26B33161B5A1B29F50036AAB /* [CP] Check Pods Manifest.lock */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
);
inputPaths = (
"${PODS_PODFILE_DIR_PATH}/Podfile.lock",
"${PODS_ROOT}/Manifest.lock",
);
name = "[CP] Check Pods Manifest.lock";
outputFileListPaths = (
);
outputPaths = (
"$(DERIVED_FILE_DIR)/Pods-Runner-checkManifestLockResult.txt",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
showEnvVarsInLog = 0;
};
3B06AD1E1E4923F5004D2608 /* Thin Binary */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;

View File

@ -4,4 +4,7 @@
<FileRef
location = "group:Runner.xcodeproj">
</FileRef>
<FileRef
location = "group:Pods/Pods.xcodeproj">
</FileRef>
</Workspace>

View File

@ -1,7 +1,7 @@
import 'package:flutter/material.dart';
class HomePage extends StatefulWidget {
HomePage({Key key, this.title}) : super(key: key);
HomePage({Key? key, required this.title}) : super(key: key);
final String title;
@override

View File

@ -1,10 +1,57 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:rsa_encrypt/rsa_encrypt.dart' as rsa;
import 'package:pointycastle/api.dart' as crypto;
import 'package:flutter/widgets.dart';
import 'package:fast_rsa/rsa.dart';
import 'package:fast_rsa/model/bridge.pb.dart';
import 'package:path_provider/path_provider.dart';
import 'dart:io';
class KeyFileManager {
static Future<String> get _localPath async {
final directory = await getApplicationDocumentsDirectory();
return directory.path;
}
static Future<File> get _pubKeyFile async {
final path = await _localPath;
return File('$path/rsa.pub');
}
static Future<File> get _privKeyFile async {
final path = await _localPath;
return File('$path/rsa');
}
static Future<KeyPair> readKeyPair() async {
try {
String privKey = await _privKeyFile.then(
(file) => file.readAsString(),
);
String pubKey = await _pubKeyFile.then(
(file) => file.readAsString(),
);
return KeyPair(
privateKey: privKey,
publicKey: pubKey,
);
} catch (e) {
print(e);
return KeyPair();
}
}
static Future<void> writeKeyPair(KeyPair pair) async {
final File privKeyFile = await _privKeyFile;
final File pubKeyFile = await _pubKeyFile;
pubKeyFile.writeAsString(pair.publicKey);
privKeyFile.writeAsString(pair.privateKey);
}
}
class KeygenPage extends StatefulWidget {
KeygenPage({Key key, this.title}) : super(key: key);
KeygenPage({Key? key, required this.title}) : super(key: key);
final String title;
@override
@ -12,76 +59,81 @@ class KeygenPage extends StatefulWidget {
}
class _KeygenState extends State<KeygenPage> {
static crypto.AsymmetricKeyPair _keyPair;
KeyPair _keyPair = KeyPair();
void _regenerateKey() {
setState(() {
_keyPair = rsa.getRsaKeyPair(rsa.RsaKeyHelper().getSecureRandom());
@override
void initState() {
super.initState();
KeyFileManager.readKeyPair().then((keyPair) {
if (!keyPair.hasPublicKey()) {
initKeyPair();
} else {
setState(() => _keyPair = keyPair);
}
});
}
String _getPublicKey() {
if (_keyPair == null)
return 'Press the button below to generate your key pair!';
return '${rsa.RsaKeyHelper().encodePublicKeyToPemPKCS1(_keyPair.publicKey)}';
Future<void> initKeyPair() async {
var keyPair = await RSA.generate(2048);
await KeyFileManager.writeKeyPair(keyPair);
setState(() {
_keyPair = keyPair;
});
}
void copyPublicKey() {
if (_keyPair.hasPublicKey()) {
Clipboard.setData(
new ClipboardData(
text: _keyPair.publicKey,
),
).then((_) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text("RSA public key copied to keyboard"),
),
);
});
} else {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text("You need to generate an RSA keypair before copying."),
),
);
}
}
@override
Widget build(BuildContext context) {
// This method is rerun every time setState is called, for instance as done
// by the _incrementCounter method above.
//
// The Flutter framework has been optimized to make rerunning build methods
// fast, so that you can just rebuild anything that needs updating rather
// than having to individually change instances of widgets.
return Scaffold(
appBar: AppBar(
// Here we take the value from the MyHomePage object that was created by
// the App.build method, and use it to set our appbar title.
title: Text('RSA Key Configuration'),
),
body: Center(
// Center is a layout widget. It takes a single child and positions it
// in the middle of the parent.
child: Column(
// Column is also a layout widget. It takes a list of children and
// arranges them vertically. By default, it sizes itself to fit its
// children horizontally, and tries to be as tall as its parent.
//
// Invoke "debug painting" (press "p" in the console, choose the
// "Toggle Debug Paint" action from the Flutter Inspector in Android
// Studio, or the "Toggle Debug Paint" command in Visual Studio Code)
// to see the wireframe for each widget.
//
// Column has various properties to control how it sizes itself and
// how it positions its children. Here we use mainAxisAlignment to
// center the children vertically; the main axis here is the vertical
// axis because Columns are vertical (the cross axis would be
// horizontal).
mainAxisAlignment: MainAxisAlignment.center,
child: LayoutBuilder(
builder: (BuildContext context, BoxConstraints constraints) {
return ListView(
children: <Widget>[
TextButton(
onPressed: () => Clipboard.setData(
new ClipboardData(
text: _getPublicKey(),
),
).then((_) {
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
content: Text("RSA public key copied to keyboard"),
));
}),
Container(
padding: const EdgeInsets.all(32),
child: TextButton(
onPressed: copyPublicKey,
child: Text(
_getPublicKey(),
_keyPair.publicKey,
style: Theme.of(context).textTheme.bodyText1,
softWrap: true,
),
style: Theme.of(context).outlinedButtonTheme.style,
),
),
ElevatedButton(
onPressed: _regenerateKey,
onPressed: initKeyPair,
child: Text('Reset RSA Key'),
style: Theme.of(context).elevatedButtonTheme.style,
),
],
);
},
),
),
);

View File

@ -6,7 +6,7 @@ import '../pages/bluetooth.dart';
import '../pages/settings.dart';
class NavBarWidget extends StatefulWidget {
NavBarWidget({Key key}) : super(key: key);
NavBarWidget({Key? key}) : super(key: key);
@override
_NavBarWidgetState createState() => _NavBarWidgetState();
@ -14,7 +14,7 @@ class NavBarWidget extends StatefulWidget {
class _NavBarWidgetState extends State<NavBarWidget> {
int _selectedIndex = 0;
StatefulWidget _selectedWidget;
Widget _selectedWidget = HomePage(title: 'Home');
static List<Widget> pages = <Widget>[
HomePage(
title: 'Home',

View File

@ -1,13 +1,6 @@
# Generated by pub
# See https://dart.dev/tools/pub/glossary#lockfile
packages:
asn1lib:
dependency: transitive
description:
name: asn1lib
url: "https://pub.dartlang.org"
source: hosted
version: "0.8.1"
async:
dependency: transitive
description:
@ -166,7 +159,7 @@ packages:
pointycastle:
dependency: transitive
description:
name: pointycastle
name: path_provider_linux
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.1"
@ -180,7 +173,7 @@ packages:
rsa_encrypt:
dependency: "direct main"
description:
name: rsa_encrypt
name: plugin_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.5"

View File

@ -29,7 +29,8 @@ dependencies:
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^1.0.2
rsa_encrypt: ^1.0.5
path_provider: ^1.6.28
fast_rsa: ^1.1.4
dev_dependencies:
flutter_test: