Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Welcome to our site

Take a moment to join our board

Search the Community

Showing results for tags '5017-client'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Community
    • Announcements
    • Applications
    • Introductions
    • Off-Topic
  • Programming
    • Game Programming
    • General Programming
    • Web Programming
  • Private Servers
    • Conquer Online
  • Team Rocket's HQ
  • Team Rocket's Double Trouble

Product Groups

There are no results to display.

Blogs

There are no results to display.

There are no results to display.


Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Country


Languages


Sources


Website

Found 1 result

  1. W1cked

    RC5 Package - Go

    I had help from @Spirited to figure this stuff out and port it to Go. I know a lot of people in the emulator communities don't use Go, but I hope with more packages released it will lift the barrier for people to use it. It's pretty straight forward, use the NewRC5 method instead of a struct literal. Encrypt by calling Encrypt and supplying a dst byte slice the same size as the src slice. For Decrypting, do the same thing. This adheres to the Cipher.Block interface, so for your client/conn structs you can just use that interface type. package rc5 import ( "encoding/binary" "math/bits" ) const ( WordSize = 16 Rounds = 12 KeySize = WordSize / 4 SubSize = 2 * (Rounds + 1) ) type RC5 struct { Key []uint32 Sub []uint32 } func NewRC5() RC5 { c := RC5{} c.Key = make([]uint32, KeySize) c.Sub = make([]uint32, SubSize) //Conquer default key c.generateKeys([]byte{ 0x3C, 0xDC, 0xFE, 0xE8, 0xC4, 0x54, 0xD6, 0x7E, 0x16, 0xA6, 0xF8, 0x1A, 0xE8, 0xD0, 0x38, 0xBE, }) return c } func (r *RC5) generateKeys(buf []byte) { //Initialize key expansion //seedLength := len(buf) / WordSize * WordSize for i := 0; i < KeySize; i++ { r.Key[i] = binary.LittleEndian.Uint32(buf[i*4:]) } //Generate r.Sub r.Sub[0] = 0xB7E15163 for i := 1; i < SubSize; i++ { r.Sub[i] = r.Sub[i-1] - 0x61C88647 } //Generate key vector var a, b uint32 var i, j int for x := 0; x < 3*SubSize; x++ { r.Sub[i] = bits.RotateLeft32(r.Sub[i]+(a+b), 3) a = r.Sub[i] r.Key[j] = bits.RotateLeft32(r.Key[j]+(a+b), int(a+b)) b = r.Key[j] i = (i + 1) % SubSize j = (j + 1) % KeySize } } func (r *RC5) Encrypt(dst, src []byte) { length := len(src) / 8 if (len(src) % 8) > 0 { length = length + 1 } copy(dst, src) for word := 0; word < length; word++ { a := binary.LittleEndian.Uint32(dst[8*word:]) + r.Sub[0] b := binary.LittleEndian.Uint32(dst[(8*word + 4):]) + r.Sub[1] for round := 1; round <= Rounds; round++ { a = bits.RotateLeft32(a^b, int(b)) + r.Sub[2*round] b = bits.RotateLeft32(b^a, int(a)) + r.Sub[2*round+1] } binary.LittleEndian.PutUint32(dst[8*word:], a) binary.LittleEndian.PutUint32(dst[8*word+4:], b) } } func (r *RC5) Decrypt(dst, src []byte) { length := len(src) / 8 if (len(src) % 8) > 0 { length = length + 1 } copy(dst, src) for word := 0; word < length; word++ { a := binary.LittleEndian.Uint32(dst[8*word:]) b := binary.LittleEndian.Uint32(dst[(8*word)+4:]) for round := Rounds; round > 0; round-- { b = bits.RotateLeft32(b-r.Sub[2*round+1], -int(a)) ^ a a = bits.RotateLeft32(a-r.Sub[2*round], -int(b)) ^ b } binary.LittleEndian.PutUint32(dst[8*word:], a-r.Sub[0]) binary.LittleEndian.PutUint32(dst[8*word+4:], b-r.Sub[1]) } } func BlockSize() int { return 8 }
×

Important Information

By using this site, you agree to our Terms of Use.