-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
240 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,3 +24,5 @@ | |
*.orig | ||
*cpk | ||
.idea/* | ||
.DS_Store | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// | ||
// MyDialog.h | ||
// keychain | ||
// | ||
// Created by Mikhail Lutskiy on 29/10/2018. | ||
// | ||
|
||
#import <Cocoa/Cocoa.h> | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
@interface MyDialog : NSWindowController | ||
- (instancetype)initWithFrame:(NSRect)frame; | ||
- (void)runModal; | ||
@end | ||
|
||
NS_ASSUME_NONNULL_END |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
// | ||
// MyDialog.m | ||
// keychain | ||
// | ||
// Created by Mikhail Lutskiy on 29/10/2018. | ||
// | ||
|
||
#import "MyDialog.h" | ||
#import "PassSyncStore.h" | ||
|
||
@interface MyDialog () { | ||
NSSecureTextField *pass; | ||
} | ||
|
||
@end | ||
|
||
@implementation MyDialog | ||
|
||
- (instancetype)initWithFrame:(NSRect)frame { | ||
NSWindowStyleMask windowMask = NSWindowStyleMaskTitled | ||
| NSWindowStyleMaskClosable; | ||
NSWindow *window = [[NSWindow alloc] initWithContentRect:frame | ||
styleMask:windowMask | ||
backing:NSBackingStoreBuffered | ||
defer:NO]; | ||
[window setTitle:@"Keychain"]; | ||
[window makeKeyAndOrderFront:self]; | ||
[window orderFront:self]; | ||
|
||
[NSNotificationCenter.defaultCenter addObserver:self | ||
selector:@selector(windowWillClose:) | ||
name:NSWindowWillCloseNotification | ||
object:nil]; | ||
|
||
return [super initWithWindow:window]; | ||
} | ||
|
||
- (void) clickButton { | ||
[[PassSyncStore sharedInstance] setPass:pass.stringValue]; | ||
[self.window close]; | ||
} | ||
|
||
- (void)dealloc { | ||
[NSNotificationCenter.defaultCenter removeObserver:self]; | ||
} | ||
|
||
- (void)runModal { | ||
pass = [[NSSecureTextField alloc] initWithFrame:CGRectMake(50, 100, 100, 25)]; | ||
pass.placeholderString = @"Password"; | ||
[self.window.contentView addSubview:pass]; | ||
NSButton *button = [NSButton buttonWithTitle:@"Sign" target:self action:@selector(clickButton)]; | ||
[self.window.contentView addSubview:button]; | ||
[[NSApplication sharedApplication] runModalForWindow:self.window]; | ||
} | ||
|
||
- (void)windowWillClose:(NSNotification *)notification { | ||
[NSApp setActivationPolicy:NSApplicationActivationPolicyProhibited]; | ||
dispatch_async(dispatch_get_main_queue(), ^{ | ||
[NSApp stopModal]; | ||
}); | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// | ||
// PassSyncStore.h | ||
// keychain | ||
// | ||
// Created by Mikhail Lutskiy on 31/10/2018. | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
@interface PassSyncStore : NSObject | ||
|
||
@property (atomic, strong) NSString *pass; | ||
|
||
+ (instancetype)sharedInstance; | ||
@end | ||
|
||
NS_ASSUME_NONNULL_END |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// | ||
// PassSyncStore.m | ||
// keychain | ||
// | ||
// Created by Mikhail Lutskiy on 31/10/2018. | ||
// | ||
|
||
#import "PassSyncStore.h" | ||
|
||
@implementation PassSyncStore | ||
|
||
+ (instancetype)sharedInstance | ||
{ | ||
static PassSyncStore *sharedInstance = nil; | ||
static dispatch_once_t onceToken; | ||
dispatch_once(&onceToken, ^{ | ||
sharedInstance = [[PassSyncStore alloc] init]; | ||
}); | ||
return sharedInstance; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// | ||
// sec_mod_mac.hpp | ||
// keychain | ||
// | ||
// Created by Mikhail Lutskiy on 29/10/2018. | ||
// | ||
//#ifdef __OBJC__ | ||
//#ifndef sec_mod_mac_hpp | ||
//#define sec_mod_mac_hpp | ||
|
||
#include <keychain_lib/keychain_wrapper.hpp> | ||
|
||
namespace keychain_app | ||
{ | ||
|
||
class sec_mod_mac: public secure_dlg_mod_base | ||
{ | ||
public: | ||
sec_mod_mac(); | ||
virtual ~sec_mod_mac(); | ||
virtual keychain_app::byte_seq_t get_passwd_trx_raw(const std::string& raw_trx, std::string binary_dir) const override; | ||
virtual keychain_app::byte_seq_t get_passwd_on_create(std::string binary_dir) const override; | ||
virtual void print_mnemonic(const string_list& mnemonic) const override; | ||
private: | ||
static constexpr const char* pass_str = "blank_password"; | ||
}; | ||
|
||
} | ||
|
||
//#endif //KEYCHAINAPP_SEC_MOD_LINUX_HPP | ||
//#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// | ||
// sec_mod_mac.cpp | ||
// keychain | ||
// | ||
// Created by Mikhail Lutskiy on 29/10/2018. | ||
// | ||
|
||
#include "sec_mod_mac.hpp" | ||
#import <Foundation/Foundation.h> | ||
#import "MyDialog.h" | ||
#import "PassSyncStore.h" | ||
|
||
using namespace keychain_app; | ||
|
||
sec_mod_mac::sec_mod_mac() | ||
{} | ||
|
||
sec_mod_mac::~sec_mod_mac() | ||
{} | ||
|
||
|
||
void sec_mod_mac::print_mnemonic(const string_list& mnemonic) const | ||
{ | ||
} | ||
|
||
byte_seq_t sec_mod_mac::get_passwd_trx_raw(const std::string& raw_trx, std::string binary_dir) const | ||
{ | ||
[NSApplication sharedApplication]; | ||
[NSApp setActivationPolicy:NSApplicationActivationPolicyRegular]; | ||
[NSApp activateIgnoringOtherApps:YES]; | ||
|
||
NSRect frame = NSMakeRect(0, 0, 200, 200); | ||
MyDialog *dialog = [[MyDialog alloc] initWithFrame:frame]; | ||
[dialog runModal]; | ||
std::string str = std::string([[[PassSyncStore sharedInstance] pass] UTF8String]); | ||
[[PassSyncStore sharedInstance] setPass:@""]; | ||
keychain_app::byte_seq_t pass(str.begin(), str.end()); | ||
return pass; | ||
} | ||
|
||
byte_seq_t sec_mod_mac::get_passwd_on_create(std::string binary_dir) const | ||
{ | ||
[NSApplication sharedApplication]; | ||
[NSApp setActivationPolicy:NSApplicationActivationPolicyRegular]; | ||
[NSApp activateIgnoringOtherApps:YES]; | ||
|
||
NSRect frame = NSMakeRect(0, 0, 200, 200); | ||
MyDialog *dialog = [[MyDialog alloc] initWithFrame:frame]; | ||
[dialog runModal]; | ||
std::string str = std::string([[[PassSyncStore sharedInstance] pass] UTF8String]); | ||
[[PassSyncStore sharedInstance] setPass:@""]; | ||
keychain_app::byte_seq_t pass(str.begin(), str.end()); | ||
return pass; | ||
} |