SSLSocketChannel (for Dean & anyone else interested in the topic)

In my SSLSocketChannel implementation I've come across the following problem situation that I'm not sure how to handle.
Assume we have an SSLSocketChannel which provides a write(ByteBuffer) method which both wraps and writes to the channel, much as for SSLSocket.
If data (plaintext) is wrapped into the SSLEngine's netSendBuffer (as ciphertext) and then written to the channel and a short write occurs, part of the ciphertext has been sent, and you must complete this write before any other wraps & writes, otherwise the peer will fail to decrypt the partial ciphertext received.
But, what should be returned to the application by the write which came up short?
You can't return the actual write count because that's measured in ciphertext not plaintext. You can't return zero because part of the ciphertext has been written and you don't want the application to retry the entire write, otherwise the plaintext will be repeated when recovered at the peer. You can't return a value representing the amount of plaintext that has been ciphered and written because you don't know that value, and in fact it generally doesn't really exist because the partially-written ciphertext is generally a function of the entire plaintext buffer, not just the leading piece of it.
So, I conclude that you can't really tell the application about the short write. So you have now gotten a phase behind the application - you have data left to write which it thinks you have already written. You can retry the write before the next wrap operation, and if it succeeds OK, or if it comes up short again now you can return zero (i.e. before you do the next wrap), and so on, and this actually goes on quite well - until it comes time to close the channel.
At the point of closing, you may still have unwritten ciphertext which you must write. You may be in non-blocking mode, so you really shouldn't block until it is written, and if you get a short write again what do you do now? Fail to close (throw an exception)?

Well, you could have close throw the exception, have isBufferEmpty() and flushBuffer() methods, and document that you should always wait until you can select for a OP_WRITE before closing unless you want to check the buffer.
Alternatively you could have a background thread that sends all the stuff in the buffers of closed SSLSocketChannels, but that doesn't seem like that good an idea.

Similar Messages

  • I just bought the Otterbox Ipad2...anyone else interested in the new bulletproof case?

    ...anyone else interested in the new bulletproof case?

    I have the defender on my iPad 1 and it will keep your iPad much more secure than any other case I have seen.
    It does, however, add over a pound to the iPad and that is just too much for me since my 'home' doesn't usually bounce around much. The smart cover coupled with the clear Xgear rear cover is enough for me.
    If Otterbox comes out with a reduced weight 'commuter' case for the iPad 2 I will revisit the issue.

  • Does anyone else think that the AppleMac group of products are marketed in a greedy way? I have MacBook Pro 10.5.8 and am now told that I have to upgrade to Snow Leopard to sync my new iPad. Of course there isn't enough memory on the MacBook? I'm angry!

    Does anyone else think that the AppleMac group of products are marketed in a greedy way? I have MacBook Pro 10.5.8 with Leopard and am now told that I have to upgrade to Snow Leopard so that my system can download the relevant iTunes upgrade to sync my new iPad and get my audiobooks (which don't appear anywhere on the device right now). Of course there isn't enough memory on the MacBook and Snow Leopard costs more also? I don't have financial resources to pay for all the new memory requirement and related upgrades they say I need just to sync my iPad with my purchases.

    Thanks for the reply but I already knew this. $20 for Snow Leopard which asks for 5gb free memory. I can only see that I have 4 gb (which I feel is rather a pathetic amount of available memory for any computer). To upgrade this computer's memory will cost another fee (I haven't researched this yet but gather it's more than $20). Then of course I could also be told that the OSX Mackbook Pro that I have can't be memory upgraded - which means I'm being told to buy a new computer - hence my very frustrated last email. I have been given a lovely iPad 2 as a present and now can't sync at all with anything because of this ongoing upgrade nightmare. How on earth am I going to be able to sync my movies, audiobooks etc to this new device??

  • Does anyone else feel that the iPhone is sluggish after update 1.1.1?

    Is it just me or does anyone else feel that the iPhone feels more sluggish after update 1.1.1? I haven't unlocked or hacked the phone in any way and so it must be due to the update. I thought that the sluggish behavior could be due to a recent update and so I reset the phone. But I still feel that the iPhone has lost that responsiveness that it used to have before. Any one else experiencing this?

    Yes, without question I thought typing, especially, was sluggish at first. However, after a day it has seemed to speed up and now, I'd say, is back to original performance, or close to it.
    Also, I have lots of contacts (2500), and the phone has been very slow to make the first identification of email addresses when I start typing. Specifically, it freezes for several seconds after the first letter is typed. However, I believe that process is a bit faster after this update.
    Derek

  • Just wondered if anyone else is experiencing the following problem and knows a solution. I know a few friends who are also having the issue so its obviously something wrong with IOS7.   Basically I have an iphone 4 and upgraded to v7 and most recently v7.

    Just wondered if anyone else is experiencing the following problem and knows a solution. I know a few friends who are also having the issue so its obviously something wrong with IOS7.
    Basically I have an iphone 4 and upgraded to v7 and most recently v7.0.2. When I am on calls the phone started to beep and vibrate and sometimes change the call to speaker. It seems to be that the screen is sometimes active whilst on calls and so my ear is actually pressing the buttons and hitting numbers or changing it to speaker phone. It has also cancelled a call a few times.
    This is extremely annoying and makes every call a worry.
    Any ideas of how to solve this problem?

    I have taken it back to the Apple store genius bar, but they say they don't see anything wrong. Well unless you use it all day and experience the problems when they happen, you wont see anything wrong. But there are lots wrong with it. But this would be the same store as I purchased the phone. And they backed up my old Iphone 4, but were not able to get anything to load back onto my new phone. So, I lost pretty much everything. But over time, some of my contacts have started showing up, although i am still missing over 800 of them.

  • Has anyone else complained about the battery time provided with a busy iphone5

    Has anyone else complained about the battery time provided with a busy iphone5

    Here's some tips to extend the battery life: http://helpios7.com/ios-7-battery-issues/

  • Is anyone else disappointed by the nano 1st generation replacement programme?  I received a tiny mini nano in replacement for my recalled one - I at least expected something the same size and functionality!

    I wondered if anyone else also got a tiny replacement that was not really like for like.  Or am I the only one?

    Because it is smaller it is not like for like?
    Sell it on the open market, lots of people are looking for refurbished Generation 6 Nanos.
    See what I mean: https://discussions.apple.com/thread/4750990?tstart=0
    Message was edited by: deggie

  • Has anyone else noticed that the iOS 6 Maps App is missing the area code for many places it has listed?

    If I try to look up a local business on the Maps App it drops a pin on all of the locations matching my search parameters. However, when I get details about a dropped pin, the phone number is usually missing the area code! For example, if the phone number is +1 (123) 555-5555 it would show up as +1 (555) 555-5. This makes it impossible to call directly from the maps app or to copy and paste infront of a manually entered area code (because of the '+1'). Has anyone else noticed this?

    Have you checked to make sure that your region settings are correct?
    Settings>General>International>Region Format

  • Anyone else annoyed by the seriously slow interface (not internet)

    I've had an iphone since it first came out, and ever since version 2.0 came out, it's been really hard to deal with some of the amazingly slow interface problems it has now. I got the 3g about a month after it first came out, so I'm using that one now.
    My problem is that nearly every application takes at least 5 seconds to load. + or - about 2 seconds, sometimes up to 10. That's a really really long time for an application to boot up. It even does that on the phone and text message applications.
    Even worse is the time it takes to load up the search bar on apps google maps or youtube. Once I've already waited 5 seconds for it to load up, I press the search and have to wait ANOTHER 5 seconds for the keyboard to load up. Even better is I'm not sure I actually pressed it right so sometimes I'll press it again and then the bookmarks will come up when it finally loads....blah. Not to mention even more lag as I try to type. I've tested some of my friend's iphones and they're about as slow as mine, maybe a little faster, but still slow enough to be a pain. Anyone else having problems like this? Or does it just not bother you?
    I've messed with my friends' blackberry phones and I feel like the turtle on those comcast commercials. I press facebook and it's right there...immediately...and I freak out. I show anyone my iphone now and they lose interest before it loads!
    Also, any pointers to speed it up? I know I have a couple pages of applications, so I'm sure if I deleted every app it may go a lot faster, but that doesn't sound like a good solution. I'm also wondering why it's going so slow in the first place. Back in the days of 1.x I had no trouble loading stuff up. Now I'm embarassed to try to show people things on my phone because I press the application and have to practically start another conversation before I can show what I want to show.
    Well there's my rant, I hope 2.2 does a lot of optimizations, because that's the only gripe I have about my phone right now, I can live with some things not existing.

    Just found this post and would like to contribute. My 3G iPhone is very slow and always has been since I bought it last summer. I've been through all the updates that have been issued and now on 2.2 there is no difference.
    In contacts when I press an alphabetical key absolutely nothing happens for 6-7 seconds. When typing an SMS the first letter pressed genies up large and stays like that for 7-8 seconds before it will genie back down and allow me to type the next character. E-mail does the same but sticks on the first character for only 3-4 seconds, wow I'm lucky here then.
    I have Mobile Me and this definitely contributes to the problem, ie with Mobile Me not engaged this awful problem of lag is not there. I booked an appointment at an Apple store in the Genius Bar to show them the problem but their Genius decided it was all due to me having too many contacts, 1885 that I should expect this behaviour and I just had to live with it !
    Not what I was expecting, appalling service and it just came across that he was making it up as he went along. I'd say this is a major problem for Apple and they have directed their staff not to replace the handsets as they know full well what the problem is and a new handset won't cure it.
    Wish they'd rectify this problem properly as it's really spoiling the user experience, slowing down my work and is totally embarrassing to show what should be a cutting edge device to others.

  • Anyone else interested in pursuing a lawsuit against verizon?

    Hello all, I have read the verizon privacy policy several times and still can't find the section on violating our privacy to assist our incompetent government.  I have an appointment with my attorney next week to get some feedback on filing a lawsuit against them.  I will post what I find out on here.  Please let me know if anyone else is interested in pursuing this cause with me.

    Verizon was obligated to comply with the FISA warrant.  Their failure was in their Privacy disclosure:  They did not indicate that such orders may exist. (And I did go back and re-read the **** thing.)  As for me, I'm going after the government.  I've already started talking to the ACLU to join a class.  In particular b/c I have no other carrier where I live, and the only declassified warrant applies to the only carrier I can use.  (Now, of course, it's accepted that all the major carriers were also served with these warrants, but the others have not been declassified.)  I suppose a case could be made for the failure of the company to advise customers of the privacy issue.  Good luck.
    >> profanity removed <<
    Message was edited by: Verizon Moderator

  • Is anyone else dissatisfied with the new lollipop upgrade?

    I'm frustrated with the lollipop change to silence (mute) phone procedure!  And also frustrated that I can't find any DETAILED description of the upgrade changes to my phone and how to access/use them.  Anyone else?

    I am incredibly upset with the lollipop and kitkat upgrade. I had a brand new S5 I bought in February. When the first time I upgraded it the phone started to have issues. It was only 2 months old. It would lock up continuously, overheat, delay or not even send out my text messages until the phone was hard reset or rebooted. I even did a factory reset on the phone and the problems still existed. My contacts would throw an error as well and need to be shut down.
    I went to the my local Verizon store and told them my issues with the phone after the upgrade. All they were able to do was send me out a refurbished replacement phone while the phone is under warranty. I think that if the phone needs to be replaced that at least you should receive a new phone instead of a refurbished one. Especially seeing that I had absolutely no problem with the original phone until i updated it with lollipop and kitkat. the old phone was never dropped or damaged in any way. it even had a life proof case on it!
    I currently have a "new" refurbished phone from Verizon. and it came with the original OS on it. I have refused the updates now for 2 weeks. and it seems as if the phone is acting up a little bit after every time I refuse to update it. But it still is nothing like how the other phone acted after the update!

  • Is anyone else afraid of the new 14,338 word iTunes license?

    I opened iTunes today, went to purchase a song and was presented with a new iTunes (Australia) license which scared me a little, the thing is over 14 thousand words, of which I don't have a great deal of time or effort to read. Why is it so long? Couldn't it be more consice? I'm sure that there would be a lot of people that would see how long it is and simply click `Accept'.
    Does anyone else agree with this?
    I'm considering not using iTunes anymore because the license has gotten a little too complicated for me.

    Why is it so long? One word: lawyers. Not only Apple's but those of the content providers, all of whom want to cover all possible contingencies. The other download stores that offer similar content and services have agreements of similar length.
    I haven't gone over the new agreement word by word to compare it with the former version, but I don't see anything significant that's changed. If you don't want to agree to the new agreement, though, it's your call. But you'll need to wade through similar legalese on any download store you want to use.
    Regards.

  • Anyone Else Disappointed With The Performance?

    Anyone else kind of disappointed at the performance of the beta version of Safari?
    Seems awfully slow to load pages and surf after I installed. Not sure if it's just because it's still in development or whatever. Just wanted to get some thoughts.

    Hi,
    NO, I'm not using any BETA version at all ...
    I'll will wait for the official release fro Apple.
    Dimaxum

  • Anyone else noticed that the upload to iCloud from Photos.app takes a very long time?

    I have a Photos library that weight about 60 gig. I have 200 gig on iCloud. Photos have now been sending data  for over 12 hours at a 200 K/sec pace. Has anyone else experienced slow sending? Anyone who has an idea of what I can do? Or maybe it's just a very long way to send images from Sweden to US and back again to my other devices.

    Part of the issue is that Apple's servers are likely under some strain. The other part of it is, how fast is your upload from your ISP? 5Mbps upload is the standard for most Americans, but that only means 625KB/sec maximum.
    Apple appears to be aware of how long large libraries will take to first upload, which is why Photos preferences offers the option to pause the upload for a day. That implies to me that this will take many days to upload completely.

  • Anyone else annoyed by the bug in Repeat...Controls setting?

    I have noticed a bug in iTunes since Version 11.
    It has to do with the Controls...Repeat setting. Back in Version 10 I could independently set each playlist to Repeat or not.
    Now, in Version 11, this Controls...Repeat setting controls ALL playlists globally. So, now there is no possibility of having some playlists automatically repeat and some playlists just stopping at the end.
    This is a bit frustrating and has been broken for a number of revisions of iTunes.
    Is anyone else frustrated by this bug?

    Suggestions here -> http://www.apple.com/feedback/

Maybe you are looking for