Re: Share and store RSA - public key in java server and vice versa

2014-05-19 Thread Devarshi Kulshreshtha
This is what I am trying to achieve from some days now:

Approach #1:

~ Android End ~
1. Generated public and private key at an android device (using an
openssl wrapper)
2. Got modulus and exponent from the generated public key

~ iOS End ~
3. Generated public key from modulus and exponent, at ios end, using
code specified in this link:
http://stackoverflow.com/a/10643962/217586
4. Converted some sample string to an object of NSData using
NSUTF8StringEncoding
5. Used - wrapSymmetricKey:keyRef: method defined in SecKeyWrapper
class (CryptoExercise example) for encryption, and passed key obtained
from step 3 and data to encrypt obtained from step 4 to it
6. Converted NSData (encrypted data) obtained in previous step to
base64encoded string, shared the same to android guy

~ Android End ~
7. Tried to decrypt the base64encoded string, using related private key

Problem: getting error - too much data for RSA block

Approach #2: (Got to know from this link that -
https://github.com/superwills/iOSRSAPublicKeyEncryption, we are not
supposed to load public keys in iOS from anything other than a
certificate, so tried a different approach)

~ Terminal End ~
1. Generated certificate using openssl commands specified in this url:
http://stackoverflow.com/a/17295321/217586

~ iOS End ~
2. Obtained public key as specified in above url
3. Used below code to encrypt the data:

SecKeyWrapper *secKeyWrapper = [SecKeyWrapper sharedWrapper];
SecKeyRef obtainedPublicKey = [secKeyWrapper
getPublicKeyRefFromDerCertificate:kCertificatePath];
NSData *dataToBeEncrypted = [kStringToBeEncrypted
dataUsingEncoding:NSUTF8StringEncoding];
NSData *encryptedText = [secKeyWrapper
wrapSymmetricKey:dataToBeEncrypted keyRef:obtainedPublicKey];

4. Converted NSData to base64encoded string

~ Terminal End ~
5. Used below command to convert it back to original string:
echo base 64 encoded string obtained from step 4 | openssl rsautl
-decrypt -inkey rsaPrivate.pem

Problem: getting error - rsa routines:RSA_EAY_PRIVATE_DECRYPT:data
greater than mod
len:/SourceCache/OpenSSL098/OpenSSL098-47.1/src/crypto/rsa/rsa_eay.c

Any suggestions?

On Fri, May 16, 2014 at 10:40 PM, ChanMaxthon xcvi...@me.com wrote:
 Keychain is okay, I just cannot bear the crypto libraries.

 Sent from my iPhone

 On May 17, 2014, at 1:08 AM, Jens Alfke j...@mooseyard.com wrote:


 On May 16, 2014, at 12:37 AM, ChanMaxthon xcvi...@me.com wrote:

 I got fed up by Apple already and found a little BSD-licensed CXX crypto 
 library called Botan. I will either wrap it in Objective-C or rewrite it 
 for my later projects.

 I’m cautious of ‘alternative’ crypto implementations; there’s a lot of 
 complex math and logic involved that’s easy to get wrong. I want the 
 implementation I use to be as battle-tested as possible.

 Also, the Keychain is a valuable place to store secrets that, being built 
 into the OS, offers better security than anything you can do on your own or 
 with 3rd party libraries. There’s not really any other good solution for 
 storing keys, short of making the user type in a strong passphrase every 
 time they launch the app. Too bad the Keychain APIs are the worst part of 
 the Security framework :(

 —Jens
 ___

 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com

 Help/Unsubscribe/Update your Subscription:
 https://lists.apple.com/mailman/options/cocoa-dev/devarshi.bluechip%40gmail.com

 This email sent to devarshi.bluec...@gmail.com



-- 
Thanks,

Devarshi

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

History of iTunes Store music previews

2014-05-19 Thread Madhavi Gundeti
Hi,

Is there any way to save iTunes Store music/video preview history on my
Macintosh Music Library?

I am developing one Mac application to save the history of played
music/video by user(including music/video previews).

But I observed iTunes Store is not saving music/video preview history of
Anonymous user.

How to save the iTunes store music/video preview history programmatically
into Mac Music Library? Is it possible ?

Thanks and Regards,
Madhavi G.
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

'nuther dumb question

2014-05-19 Thread William Squires
  Why doesn't NSData have a +[NSData dataWithString:(NSString *)] or -[NSData 
initWithString:(NSString *)] method? i.e. how do I convert the contents of an 
NSString object into an NSData object? Why? Because -[NSFileHandle 
writeData:(NSData *)] takes an NSData object, not an NSString object. 
Arrrgg. :(
  Also, how come NSFileHandle doesn't have a -[NSFileHandle 
readFileWithSeparator:(NSString *)] method so one can read in only chunks of a 
file (of varying size, such as CSV records, or lines in a text file, separated 
by \n, as opposed to a fixed size, which could be accomplished with 
-[NSFileHandle readDataOfLength:(NSUInteger)] instead), instead of having to 
read in the whole thing? Especially on iOS, where memory space is at a premium!
  This seems like a major oversight to me... unless maybe there's a class which 
provides a higher-level of abstraction, such as NSTextFileHandle? Yeah, I can 
drop down to the C-level fopen(), fread(), fwrite(), fclose() etc... functions, 
but I'm looking for an OO-way to do this.



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: NSSharingService with Animated GIFs?

2014-05-19 Thread Ken Thomases
On May 16, 2014, at 10:26 AM, Charles Carver wrote:

 I'm pretty new to Objective-C, but have been mostly understanding everything 
 so far. I am stuck, however, on trying to share an animated GIF through 
 NSSharingService.
 
 I am attaching the image like so, where “image is a string containing the 
 URL of an animated GIF (http://i.imgur.com/V8w9fKt.gif, for example):
 
 NSImage *imageData = [[NSImage alloc] initWithContentsOfURL:[NSURL 
 URLWithString:image]];
 NSArray *shareItems = [NSArray arrayWithObjects:imageData, @“Text, nil];
 NSSharingService *service = [NSSharingService 
 sharingServiceNamed:NSSharingServiceNameComposeMessage];
 service.delegate = self;
 [service performWithItems:shareItems];
 
 When the code is run and the message is sent, however, the image gets sent 
 as a PNG file instead of a GIF.

Instead of putting an NSImage into the list, try creating an NSPasteboardItem 
and setting its data to be the image data and its type to kUTTypeGIF:

NSData* data = [NSData dataWithContentsOfURL:[NSURL URLWithString:image]];
NSPasteboardItem* item = [[NSPasteboardItem alloc] init];
[item setData:data forType:(__bridge NSString*)kUTTypeGIF];
NSArray *shareItems = [NSArray arrayWithObjects:item, @“Text, nil];
…

It may still end up as a PNG because the pasteboard server will translate from 
any known image type to the most common interchange formats, and the receiving 
end gets to pick its preferred type.

If that still doesn't work, you can try putting either the original URL into 
the shareItems array or the file URL from a locally-saved file.

Regards,
Ken


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Share and store RSA - public key in java server and vice versa

2014-05-19 Thread Jens Alfke

On May 19, 2014, at 3:06 AM, Devarshi Kulshreshtha 
devarshi.bluec...@gmail.com wrote:

 5. Used - wrapSymmetricKey:keyRef: method defined in SecKeyWrapper
 class (CryptoExercise example) for encryption, and passed key obtained
 from step 3 and data to encrypt obtained from step 4 to it

I think you’re misusing wrapSymmetricKey. The NSData you pass into it is not 
the message itself; it’s a raw symmetric key. The idea is that you create a 
symmetric key at random (probably 32 bytes for an AES-256 key), wrap (encrypt) 
that key using the recipient’s public key, encrypt your actual message using 
the symmetric key, and then send both the wrapped key and the encrypted message 
to the recipient.

 Problem: getting error - too much data for RSA block

Yup. RSA can only encrypt a block of the same size as its key, so if you’re 
using RSA-2048 the maximum block size is 256 bytes. The padding formats used 
with RSA don’t support messages longer than that. In practice, the only things 
RSA encrypts are symmetric keys, never messages.

(If you’re not familiar with concepts like wrapping and padding, you should 
really read a good book on cryptography before proceeding. It’s actually rather 
dangerous to work on this kind of stuff without a solid understanding of the 
principles, because the crypto building blocks can easily be misused to create 
systems that are insecure and easily exploited.)

—Jens
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Not getting mouseDown: called when control-clicking in view in menu item

2014-05-19 Thread Lee Ann Rucker
NSView handles rightMouseDown: differently - it calls calls menuForEvent: 
Documentation says in 10.7+ it should pass it up the responder chain, so you 
ought to get it.

I'd put a symbolic break on -[NSView rightMouseDown:] and see if it's being 
called; that might shed some light on where it's going.


On May 16, 2014, at 8:11 AM, Tim Hewett wrote:

 I have tried that too, no message for that either.
 
 Tim.
 
 
 On 16 May 2014, at 14:30, Eric Shepherd the.she...@gmail.com wrote:
 
 Try implementing rightMouseDown: instead for that.
 
 Eric Shepherd
 
 On May 15, 2014, at 12:39 PM, Tim Hewett tghewe...@onetel.com wrote:
 
 I have a NSMenuItem with a custom view (inheriting from NSImageView) which 
 needs to react to mouseDown: events. An NSTrackingArea has been setup for 
 the view’s frame to enable this.
 
 When getting the events the modifierFlags are used to change behaviour, but 
 this doesn’t work when control is held down - no mouseDown: event occurs at 
 all (no problem with other modifier keys).
 
 If mouseDown: is called with no modifier keys held down and then control is 
 pressed, this can be seen in the modifier flags when the mouseUp: event 
 occurs.
 
 The TrackView in the MenuItemView sample code has been tested and gets 
 mouseDown: events including when control is held down, the only difference 
 seems to be that the view in that sample is defined in a XIB while the 
 problem code’s view is created programmatically. 
 
 Is there a way that this app can get mouseDown: events when control is 
 being held down?
 ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com
 
 Help/Unsubscribe/Update your Subscription:
 https://urldefense.proofpoint.com/v1/url?u=https://lists.apple.com/mailman/options/cocoa-dev/the.sheppy%2540gmail.comk=oIvRg1%2BdGAgOoM1BIlLLqw%3D%3D%0Ar=yJFJhaNnTZDfFSSz1U9TSNMmxGyib3KjZGuKfIhHLxA%3D%0Am=coyti1S6AoDBJ2Iq%2Fk5SXe5EGAtaBJ%2Bgszt9rNM7m3w%3D%0As=b1221be697f631761fc1d184ddac0643151429eb9f0d0ae13640be539a1abfea
 
 This email sent to the.she...@gmail.com
 
 
 ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com
 
 Help/Unsubscribe/Update your Subscription:
 https://urldefense.proofpoint.com/v1/url?u=https://lists.apple.com/mailman/options/cocoa-dev/lrucker%2540vmware.comk=oIvRg1%2BdGAgOoM1BIlLLqw%3D%3D%0Ar=yJFJhaNnTZDfFSSz1U9TSNMmxGyib3KjZGuKfIhHLxA%3D%0Am=coyti1S6AoDBJ2Iq%2Fk5SXe5EGAtaBJ%2Bgszt9rNM7m3w%3D%0As=33471d3a07dc528a4858e0d13d5e9f329ec1849e4e8473187f9e0e7577cf6e73
 
 This email sent to lruc...@vmware.com


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: get set firewall status

2014-05-19 Thread Jens Alfke

On May 16, 2014, at 6:56 PM, 2551 2551p...@gmail.com wrote:

 Is there a Cocoa way to get get and set the status of the built-in OS X 
 Firewall?

It’s ipfw under the hood; a web-search for that might turn up some info. Also, 
I suggest asking on the darwin-userlevel list, which is a more appropriate 
forum for this question since it isn’t about Cocoa.

—Jens


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: mavericks style tabs

2014-05-19 Thread Lee Ann Rucker

On May 18, 2014, at 3:30 PM, SevenBits wrote:

 On May 18, 2014, at 6:22 PM, Uli Kusterer witness.of.teacht...@gmx.net 
 wrote:
 
 On 18 May 2014, at 23:06, Luther Baker lutherba...@gmail.com wrote:
 Trying my hand at some Cocoa development ... is there an SDK around the
 tabs used in Finder or Safari?
 
 If not, is there a popular library that folks are using (
 https://urldefense.proofpoint.com/v1/url?u=https://github.com/rsms/chromium-tabsk=oIvRg1%2BdGAgOoM1BIlLLqw%3D%3D%0Ar=yJFJhaNnTZDfFSSz1U9TSNMmxGyib3KjZGuKfIhHLxA%3D%0Am=ihAq%2F9sYJx0uRRRknJog%2Bz76%2FWSI%2FeU0Eg%2BZkq4RS%2FA%3D%0As=022b4bc75bb38cf30d3fe81e00ca46eb0d052c5950ac9d933cc67fd0ce296837
  ?) or is this something folks are
 generally building from ground up?
 
 Which of the features do you need? Do you need to be able to 
 drag/drop/re-arrange tabs? In any event, it may be helpful to know that 
 NSTabView can be used without a border and without actual tabs at the top, 
 as an invisible, generic paging view. So you could let that take care of 
 correctly doing display, focus-switching etc. and just create a control that 
 draws the actual tabs to click at.
 
 Of course, if you want the tabs to be on your title bar, like what Chrome and 
 the new Firefox do, you’ll need some NSWindow trickery.

 Not really - that part's easy enough with 

  [newWindow setStyleMask:[newWindow styleMask] | 
NSTexturedBackgroundWindowMask];
  [newWindow setAutorecalculatesContentBorderThickness:NO 
forEdge:NSMaxYEdge];
  [[newWindow toolbar] setShowsBaselineSeparator:NO];

 
 What I would personally do? I would create a view subclass and draw the tabs 
 myself with Core Graphics, and then add that view as a subview of the target 
 window’s theme view.

Now *that's* trickery. My tabView is in the window's contentView, no need to 
poke around in the theme view:

  NSRect tabFrame = [tabView bounds];
   NSWindow *window = [tabView window];
  /*
   * Make the border extend to just below the top of the contentFrame.
   * This will draw a line and will be where the sheet appears.
   * If we don't set it, we'll get a random one.
   */
  NSRect windowRect = [[window contentView] bounds];
  CGFloat delta = windowRect.size.height - tabFrame.size.height + 2;
  [window setContentBorderThickness:delta forEdge:NSMaxYEdge];

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: get set firewall status

2014-05-19 Thread Marco S Hyman

On May 19, 2014, at 12:02 PM, Jens Alfke j...@mooseyard.com wrote:

 It’s ipfw under the hood; a web-search for that might turn up some info. 
 Also, I suggest asking on the darwin-userlevel list, which is a more 
 appropriate forum for this question since it isn’t about Cocoa.

ipfw is deprecated.  pf -- see pfctl(8) -- is taking its place.
That may complicate things.


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: get set firewall status

2014-05-19 Thread Alex Zavatone
Out of curiosity, in which version of the OS is pf taking over for ipfw?

On May 19, 2014, at 3:26 PM, Marco S Hyman wrote:

 
 On May 19, 2014, at 12:02 PM, Jens Alfke j...@mooseyard.com wrote:
 
 It’s ipfw under the hood; a web-search for that might turn up some info. 
 Also, I suggest asking on the darwin-userlevel list, which is a more 
 appropriate forum for this question since it isn’t about Cocoa.
 
 ipfw is deprecated.  pf -- see pfctl(8) -- is taking its place.
 That may complicate things.
 


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

NSAlert - Default Cancel also respond to Escape?

2014-05-19 Thread Seth Willits

Any ideas on how to get a Cancel button which is both the default button and 
responds to escape? Both require setting the button's key equivalent and there 
can only be one. 


--
Seth Willits





--
Seth Willits




___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: get set firewall status

2014-05-19 Thread Marco S Hyman

On May 19, 2014, at 1:03 PM, Alex Zavatone z...@mac.com wrote:

 Out of curiosity, in which version of the OS is pf taking over for ipfw?

The switch started in Lion.   I don't know if ipfw has been completely
replaced. I seem to remember that some things were still being
done in ipfw.  Or maybe I'm thinking of the Application Layer
Firewall. 

Marc
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: NSAlert - Default Cancel also respond to Escape?

2014-05-19 Thread Jerry Krinock

On 2014 May 19, at 13:30, Seth Willits sli...@araelium.com wrote:

 Any ideas on how to get a Cancel button which is both the default button and 
 responds to escape? Both require setting the button's key equivalent and 
 there can only be one.

Maybe override -keyDown: somewhere.


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com