I finally got this working completely.
I am now compiling the PC app on GCC and the PC side in CW.
The key was ditching the packing and fixing the code so it didn't need the 
packing.

The only change I needed to make to keytool.cpp is to change it's assert to 
check for my new structure sizes.

The only change I needed to make in keyutility.c is to adjust the convert to 
base32 to manipulate the new structure sizes.

That's it.  I am including my chage to ConvertFromBase32 for those who follow.  
This should be all you need.  I plan to report this back to the developer of 
PORT so perhaps he will include these details in his package.

Thanks for everyone's help.

Ron

int
ConvertFromBase32(char* pcOut, const char* pcIn, int nInBytes)
{
        const char* pcCursor = pcIn;
        unsigned char acShift[5], acWorkCopy[8];
        int nValue;
        int i;  
        
        while (nInBytes > 0) {
                int nCopyableBytes = (nInBytes > 8 ? 8 : nInBytes);
                // THIS IS THE ONLY CHANGE YOU NEED
                // New structure without packcing is 8 bytes so this
                // needed to change to get working on CW
                //int nOutBytes = ((nCopyableBytes * 5) + 7) / 8;

                int nOutBytes = ((nCopyableBytes * 5) + 8) / 9;

                MEMSET(acShift, 0, sizeof(acShift));
                for (i = 0; i < nCopyableBytes; ++i) {
                        acWorkCopy[i] = *(pcCursor + nCopyableBytes - i - 1);
                }
                pcCursor += nCopyableBytes;

                for (i = 0; i < nCopyableBytes; ++i) {
                        // Make room for new bits
                        LeftShift(acShift, sizeof(acShift), 5);

                        // Put the value onto the end of the register
                        nValue = Base32Value(acWorkCopy[i]);
                        if (nValue < 0) {
                                return acWorkCopy[i];
                        }
                        acShift[0] |= nValue;
                }

                nInBytes -= nCopyableBytes;
                                
                MEMCPY(pcOut, acShift, nOutBytes);
                                
                pcOut += nOutBytes;
        }

        return 0;
}
-- 
For information on using the PalmSource Developer Forums, or to unsubscribe, 
please see http://www.palmos.com/dev/support/forums/

Reply via email to