             return nil
         }
         
+        
         let data = Data(referencing: NSData(bytes: destinationBuffer, length: size))
+
+        let calculatedChecksum = data.withUnsafeBytes { (p: UnsafeRawBufferPointer) -> Data in
+            let bytef = p.baseAddress!.assumingMemoryBound(to: Bytef.self)
+            var result = UInt32(adler32(1, bytef, UInt32(data.count))).bigEndian
+            return Data(bytes: &result, count: MemoryLayout<UInt32>.size)
+        }
         
         // checksum の検証が成功したら data を返す
-        return calcAdler32(data) == checksum ? data : nil
+        return checksum == calculatedChecksum ? data : nil
     }
 }
 

        }
    }
    
    func createAndSendReAnswer(forReOffer reOffer: String) {
        Logger.debug(type: .peerChannel, message: "create and send re-answer")
        lock.lock()

// https://developer.apple.com/documentation/accelerate/compressing_and_decompressing_data_with_buffer_compression
public final class ZLibUtil {
    
    public static func zip(_ input: Data) -> Data? {
        if input.isEmpty {
            return nil
        }
        
        let bufferSize = 262_144
        let destinationBuffer = UnsafeMutablePointer<UInt8>.allocate(capacity: bufferSize)
        
